public fit(notnull features as NDArray<T>, notnull labels as NDArray<Int>, epochs as Long = 5l, batchSize as Long = 64l, shuffle as Boolean = true, seed as Long = 12345l, verbose as Int = 1, validationData as Tuple<NDArray<T>, NDArray<Int>> = null) as TrainingHistory
Trains with shuffled minibatches and sample-weighted metrics. All derivatives are computed and checked before a batch updates parameters. Float16 uses dynamic loss scaling: overflowing batches skip every parameter and optimizer update, then reduce the scale. Finite runs raise it gradually. Full and short-tail input buffers are reused, and no sample is dropped. Calls continue from current weights; the supplied seed restarts the shuffle sequence on each fit call. Neither source tensor is modified. Optional validation runs after each epoch, with fixed parameters and dropout disabled. It is minibatched and never used for optimizer updates. Both splits are validated before the first training update.
| Parameter | Description |
|---|---|
features | Tensor [samples, ...sample dimensions]. |
labels | Int class-index vector [samples]. |
epochs | Positive number of passes over the dataset. |
batchSize | Positive maximum number of samples per batch. |
shuffle | Whether to permute training rows on each epoch. |
seed | Local shuffle seed in [1, 2147483646]. |
verbose | 0: silent; 1: every batch; 2: epoch summaries only. |
validationData | Optional (features, labels) split with the same sample shape as training; its sample count may differ. Null disables validation. |
Sample-weighted training and optional validation metrics per epoch.
history = model.fit(xTrain, yTrain, epochs=5, batchSize=64)
history = model.fit(xTrain, yTrain, validationData=(xTest, yTest))