v2026.11.2
All Bundles
Bundle

Convolutional neural networks on the CPU: layers with forward and backward passes, the Adam and SGD optimizers, an image dataset with train, validation and test splits and on-the-fly augmentation, and a training loop that records the metrics of every epoch. The layers are native (libobjk_ml, Eigen plus a small thread pool); this library holds the model API, the dataset and the trainer. Compile with -lib ml_cnn,ml,ml_lab,opencv,csv,json,cipher,gen_collect. Design, validation and measurements: docs/AI.md, "Convolutional networks (System.ML.Cnn)".

TrainingHistory

What a CnnTrainer.Fit recorded, one value per finished epoch: loss and accuracy on the training batches (as Keras reports them: running means over the epoch, in training mode, so dropout and augmentation are on and the weights change during the epoch), loss and accuracy on the validation subset (evaluation mode, after the epoch) and the wall time of the epoch.

Operations

GetEpochSeconds #

Wall-clock seconds an epoch took, training and validation together.

method : public : GetEpochSeconds(epoch:Int) ~ Float

Parameters

NameTypeDescription
epochIntepoch from 0

Return

TypeDescription
Floatseconds

GetEpochs #

The number of finished epochs.

method : public : GetEpochs() ~ Int

Return

TypeDescription
Intepochs

GetError #

Why training stopped early, empty if it ran to the end.

method : public : GetError() ~ String

Return

TypeDescription
Stringthe reason

GetTotalSeconds #

Total wall-clock seconds of all epochs.

method : public : GetTotalSeconds() ~ Float

Return

TypeDescription
Floatseconds

GetTrainAccuracy #

Training accuracy of an epoch, 0.0 to 1.0.

method : public : GetTrainAccuracy(epoch:Int) ~ Float

Parameters

NameTypeDescription
epochIntepoch from 0

Return

TypeDescription
Floataccuracy

GetTrainLoss #

Mean training loss of an epoch.

method : public : GetTrainLoss(epoch:Int) ~ Float

Parameters

NameTypeDescription
epochIntepoch from 0

Return

TypeDescription
Floatloss, 0.0 if there is no such epoch

GetValidationAccuracy #

Validation accuracy after an epoch, 0.0 to 1.0.

method : public : GetValidationAccuracy(epoch:Int) ~ Float

Parameters

NameTypeDescription
epochIntepoch from 0

Return

TypeDescription
Floataccuracy

GetValidationLoss #

Validation loss after an epoch.

method : public : GetValidationLoss(epoch:Int) ~ Float

Parameters

NameTypeDescription
epochIntepoch from 0

Return

TypeDescription
Floatloss

SaveCsv #

Writes the CSV to a file.

method : public : SaveCsv(path:String) ~ Bool

Parameters

NameTypeDescription
pathStringfile to write

Return

TypeDescription
Booltrue if written

ToCsv #

The history as CSV text with a header row: epoch, train_loss, train_accuracy, val_loss, val_accuracy, epoch_seconds (the names of the System.ML.Lab Experiment tables).

method : public : ToCsv() ~ String

Return

TypeDescription
Stringthe text

ToResultTable #

The history as a System.ML.Lab ResultTable, one row per epoch, for the Lab's text, Markdown, CSV, JSON and chart output.

method : public : ToResultTable(title:String) ~ ResultTable

Parameters

NameTypeDescription
titleStringtable title

Return

TypeDescription
ResultTablethe table