| kindling-basemodels | R Documentation |
Base models for Neural Network Training in kindling
ffnn(
formula = NULL,
data = NULL,
hidden_neurons,
activations = NULL,
output_activation = NULL,
bias = TRUE,
epochs = 100,
batch_size = 32,
penalty = 0,
mixture = 0,
learn_rate = 0.001,
optimizer = "adam",
optimizer_args = list(),
loss = "mse",
validation_split = 0,
device = NULL,
verbose = FALSE,
cache_weights = FALSE,
...,
x = NULL,
y = NULL
)
rnn(
formula = NULL,
data = NULL,
hidden_neurons,
rnn_type = "lstm",
activations = NULL,
output_activation = NULL,
bias = TRUE,
bidirectional = TRUE,
dropout = 0,
epochs = 100,
batch_size = 32,
penalty = 0,
mixture = 0,
learn_rate = 0.001,
optimizer = "adam",
optimizer_args = list(),
loss = "mse",
validation_split = 0,
device = NULL,
verbose = FALSE,
cache_weights = FALSE,
...,
x = NULL,
y = NULL
)
formula |
Formula. Model formula (e.g., y ~ x1 + x2). |
data |
Data frame. Training data. |
|
Integer vector. Number of neurons in each hidden layer. | |
activations |
Activation function specifications. See |
output_activation |
Optional. Activation for output layer. |
bias |
Logical. Use bias weights. Default |
epochs |
Integer. Number of training epochs. Default |
batch_size |
Integer. Batch size for training. Default |
penalty |
Numeric. Regularization penalty (lambda). Default |
mixture |
Numeric. Elastic net mixing parameter (0-1). Default |
learn_rate |
Numeric. Learning rate for optimizer. Default |
optimizer |
Character. Optimizer type ("adam", "sgd", "rmsprop"). Default |
optimizer_args |
Named list. Additional arguments passed to the optimizer. Default |
loss |
Character. Loss function ("mse", "mae", "cross_entropy", "bce"). Default |
validation_split |
Numeric. Proportion of data for validation (0-1). Default |
device |
Character. Device to use ("cpu", "cuda", "mps"). Default |
verbose |
Logical. Print training progress. Default |
cache_weights |
Logical. Cache weight matrices for faster variable importance. Default |
... |
Additional arguments. Can be used to pass |
x |
When not using formula: predictor data (data.frame or matrix). |
y |
When not using formula: outcome data (vector, factor, or matrix). |
rnn_type |
Character. Type of RNN ("rnn", "lstm", "gru"). Default |
bidirectional |
Logical. Use bidirectional RNN. Default |
dropout |
Numeric. Dropout rate between layers. Default |
An object of class "ffnn_fit" containing the trained model and metadata.
Train a feed-forward neural network using the torch package.
Train a recurrent neural network using the torch package.
if (torch::torch_is_installed()) {
# Formula interface (original)
model_reg = ffnn(
Sepal.Length ~ .,
data = iris[, 1:4],
hidden_neurons = c(64, 32),
activations = "relu",
epochs = 50
)
# XY interface (new)
model_xy = ffnn(
hidden_neurons = c(64, 32),
activations = "relu",
epochs = 50,
x = iris[, 2:4],
y = iris$Sepal.Length
)
}
if (torch::torch_is_installed()) {
# Formula interface (original)
model_rnn = rnn(
Sepal.Length ~ .,
data = iris[, 1:4],
hidden_neurons = c(64, 32),
rnn_type = "lstm",
activations = "relu",
epochs = 50
)
# XY interface (new)
model_xy = rnn(
hidden_neurons = c(64, 32),
rnn_type = "gru",
epochs = 50,
x = iris[, 2:4],
y = iris$Sepal.Length
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.