fit: Train a Model

fit.ggml_sequential_modelR Documentation

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 class '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 class 'ggml_functional_model'
fit(
  object,
  x,
  y,
  epochs = 1L,
  batch_size = 32L,
  validation_split = 0,
  validation_data = NULL,
  verbose = 1L,
  callbacks = list(),
  ...
)

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.

Value

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

Examples


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)


ggmlR documentation built on July 14, 2026, 1:08 a.m.