build_feature_NN: Build and compile a single Neural Network

View source: R/build_feature_NN.R

build_feature_NNR Documentation

Build and compile a single Neural Network

Description

Builds and compiles a neural network using the keras library. The architecture of the neural network is configurable using the

Usage

build_feature_NN(
  num_units,
  learning_rate = 0.001,
  activation = "relu",
  kernel_initializer = "glorot_normal",
  kernel_regularizer = NULL,
  bias_regularizer = NULL,
  bias_initializer = "zeros",
  activity_regularizer = NULL,
  loss = "mean_squared_error",
  name = NULL,
  ...
)

Arguments

num_units

Defines the architecture of each neural network. If a scalar value is provided, a single hidden layer neural network with that number of units is used. If a vector of values is provided, a multi-layer neural network with each element of the vector defining the number of hidden units on each hidden layer is used.

learning_rate

Learning rate for the neural network optimizer.

activation

Activation function of the neural network. Defaults to relu

kernel_initializer

Kernel initializer for the Dense layers. Defaults to Xavier Initializer (glorot_normal).

kernel_regularizer

Optional regularizer function applied to the kernel weights matrix.

bias_regularizer

Optional regularizer function applied to the bias vector.

bias_initializer

Optional initializer for the bias vector.

activity_regularizer

Optional regularizer function applied to the output of the layer

loss

Loss function to use during neural network training. Defaults to the mean squared error.

name

Neural Network name.

...

Arguments passed on to neuralGAM

formula

An object of class "formula": a description of the model to be fitted. You can add smooth terms using s().

data

A data frame containing the model response variable and covariates required by the formula. Additional terms not present in the formula will be ignored.

family

This is a family object specifying the distribution and link to use for fitting. By default, it is "gaussian" but also works to "binomial" for logistic regression.

bf_threshold

Convergence criterion of the backfitting algorithm. Defaults to 0.001

ls_threshold

Convergence criterion of the local scoring algorithm. Defaults to 0.1

max_iter_backfitting

An integer with the maximum number of iterations of the backfitting algorithm. Defaults to 10.

max_iter_ls

An integer with the maximum number of iterations of the local scoring Algorithm. Defaults to 10.

w_train

Optional sample weights

seed

A positive integer which specifies the random number generator seed for algorithms dependent on randomization.

verbose

Verbosity mode (0 = silent, 1 = print messages). Defaults to 1.

Value

compiled Neural Network

Author(s)

Ines Ortega-Fernandez, Marta Sestelo.

References

Kingma, D. P., & Ba, J. (2014). Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980.


neuralGAM documentation built on June 22, 2024, 6:55 p.m.