% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/model_architecture.R
\name{build_dnn}
\alias{build_dnn}
\title{Build a stacked dense (DNN) model constructor}
\usage{
build_dnn(units = NULL, layer_df = NULL, default_activation = NULL)
}
\arguments{
\item{units}{Optional integer vector of layer sizes. Ignored if
\code{layer_df} is supplied. Every layer gets \code{activation = "relu"} and
\code{use_bias = TRUE}.}

\item{layer_df}{Optional data frame / tibble with one row per layer.
Must contain a \code{units} column. May also contain any of:
\itemize{
\item \code{activation} (character)
\item \code{use_bias} (logical)
\item \code{kernel_initializer}, \code{bias_initializer} (character, or a
list-column of initializer objects, e.g.
\code{keras3::initializer_he_normal()})
\item \code{kernel_regularizer}, \code{bias_regularizer},
\code{activity_regularizer} (list-column; each element is either
\code{NULL} or an object like \code{keras3::regularizer_l2(0.01)})
\item \code{name} (character, layer name)
}
Any column not supplied falls back to \code{layer_dense()}'s own default.
Columns holding actual keras objects (regularizers, and
initializers if you don't just want a string) must be \emph{list-columns}
so each row can carry a different object or NULL, e.g.:
\preformatted{
tibble::tibble(
  units = c(64, 32, 1),
  activation = c("relu", "relu", "linear"),
  kernel_regularizer = list(keras3::regularizer_l2(0.001), NULL, NULL)
)
}}

\item{default_activation}{Activation function to be used if not otherwise
specified in \code{layer_df}.}
}
\value{
A function of a single argument \code{inputs} (a keras input
tensor) that returns a \code{keras3::keras_model()}.
}
\description{
Returns a \emph{function} \code{function(inputs) {...}} — not a model itself —
that builds a feed-forward stack of \code{layer_dense()} calls on top of
whatever \code{inputs} tensor it is later called with, and returns the
resulting \code{keras3::keras_model()}.
}
\details{
Layers can be specified either as a simple vector of unit counts, or
as a data frame / tibble giving full per-layer control over
activation, use_bias, initializers, regularizers, layer name, etc.
}
\examples{
\dontshow{if (reticulate::py_module_available(tensorflow)) withAutoprint(\{ # examplesIf}
mod_units <- build_dnn(units = c(16, 8, 1))
mod_df <- build_dnn(layer_df = data.frame(
  units = c(32, 16, 8, 1),
  activation = c("relu", "relu", "relu", "linear"),
  use_bias = c(FALSE, FALSE, FALSE, TRUE)
))
\dontshow{\}) # examplesIf}
}
