Learn R Programming

ggmlR (version 0.8.1)

fit.ggml_sequential_model: Train a Model

Description

Trains the model on data for a fixed number of epochs. This is the keras-compatible interface; it delegates to ggml_fit.

Usage

# S3 method for ggml_sequential_model
fit(
  object,
  x,
  y,
  epochs = 1L,
  batch_size = 32L,
  validation_split = 0,
  validation_data = NULL,
  verbose = 1L,
  callbacks = list(),
  ...
)

# S3 method for ggml_functional_model fit( object, x, y, epochs = 1L, batch_size = 32L, validation_split = 0, validation_data = NULL, verbose = 1L, callbacks = list(), ... )

Value

The trained model (invisibly), with model$history.

Arguments

object

A compiled model object.

x

Training data. Matrix, array, or list of matrices (multi-input).

y

Training labels (matrix, one-hot encoded for classification).

epochs

Number of training epochs (default 1).

batch_size

Batch size (default 32).

validation_split

Fraction of data for validation (default 0).

validation_data

Optional list(x_val, y_val).

verbose

0 = silent, 1 = progress (default 1).

callbacks

List of callback objects (default list()).

...

Additional arguments passed to ggml_fit.

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")
# model <- fit(model, x_train, y_train, epochs = 5, batch_size = 32)
# }

Run the code above in your browser using DataLab