Learn R Programming

ggmlR (version 0.8.1)

compile.ggml_sequential_model: Compile a Model

Description

Configures the model for training by setting the optimizer, loss function, and metrics. This is the keras-compatible interface; it delegates to ggml_compile.

Usage

# S3 method for ggml_sequential_model
compile(
  object,
  optimizer = "adam",
  loss = "categorical_crossentropy",
  metrics = c("accuracy"),
  ...
)

# S3 method for ggml_functional_model compile( object, optimizer = "adam", loss = "categorical_crossentropy", metrics = c("accuracy"), ... )

Value

The compiled model (invisibly).

Arguments

object

A model object (e.g. ggml_sequential_model or ggml_functional_model).

optimizer

Character: "adam", "adamw", or "sgd".

loss

Character: "categorical_crossentropy" or "mse".

metrics

Character vector of metrics (default "accuracy").

...

Additional arguments passed to ggml_compile.

Examples

Run this code
# \donttest{
model <- ggml_model_sequential() |>
  ggml_layer_dense(10, activation = "softmax", input_shape = 4)
model <- compile(model, optimizer = "adam",
                 loss = "categorical_crossentropy")
# }

Run the code above in your browser using DataLab