klyn.math.nn.Sequential.fit
method
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
Description

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.

Parameters
ParameterDescription
featuresTensor [samples, ...sample dimensions].
labelsInt class-index vector [samples].
epochsPositive number of passes over the dataset.
batchSizePositive maximum number of samples per batch.
shuffleWhether to permute training rows on each epoch.
seedLocal shuffle seed in [1, 2147483646].
verbose0: silent; 1: every batch; 2: epoch summaries only.
validationDataOptional (features, labels) split with the same sample shape as training; its sample count may differ. Null disables validation.
Returns

Sample-weighted training and optional validation metrics per epoch.

Throws
  • ValueException for invalid options/data or non-finite loss/gradients.
  • NullException if features, labels is null at runtime; statically null arguments are rejected with TypeError.
Example

history = model.fit(xTrain, yTrain, epochs=5, batchSize=64)

history = model.fit(xTrain, yTrain, validationData=(xTest, yTest))