| ggml_default_mlp | R Documentation |
Constructs an uncompiled sequential multi-layer perceptron suitable as a
starting point for tabular classification or regression. This is the default
model_fn used by LearnerClassifGGML and LearnerRegrGGML
when the user does not supply a custom builder, and it is also exported for
direct use or as a template for user-defined builders.
ggml_default_mlp(
n_features,
n_out,
task_type = c("classif", "regr"),
hidden_layers = c(128L, 64L),
activation = "relu",
dropout = 0.2
)
n_features |
Integer. Number of input features. Required. |
n_out |
Integer. Number of output units. For classification this is the number of classes; for regression this is typically 1. |
task_type |
Character. One of |
|
Integer vector. Widths of the hidden dense layers.
Default | |
activation |
Character. Activation applied to each hidden layer.
Default |
dropout |
Numeric in |
The returned model is not compiled: the caller is responsible for
calling ggml_compile with the appropriate loss
("categorical_crossentropy" for classification, "mse" for
regression) before training.
The final layer is chosen based on task_type:
"classif" — dense with units = n_out and softmax activation.
"regr" — dense with units = n_out and no activation
(identity / linear output).
An uncompiled ggml_sequential_model object. Call
ggml_compile before ggml_fit.
ggml_model_sequential, ggml_layer_dense,
ggml_layer_dropout, ggml_compile
## Not run:
# 3-class classifier on 20 features
model <- ggml_default_mlp(
n_features = 20L,
n_out = 3L,
task_type = "classif",
hidden_layers = c(64L, 32L),
dropout = 0.1
)
model <- ggml_compile(model, optimizer = "adam",
loss = "categorical_crossentropy")
# Single-output regressor
reg <- ggml_default_mlp(
n_features = 10L,
n_out = 1L,
task_type = "regr"
)
reg <- ggml_compile(reg, optimizer = "adam", loss = "mse")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.