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
- GetEpochs
- GetError
- GetTotalSeconds
- GetTrainAccuracy
- GetTrainLoss
- GetValidationAccuracy
- GetValidationLoss
- SaveCsv
- ToCsv
- ToResultTable
GetEpochSeconds #
Wall-clock seconds an epoch took, training and validation together.
method : public : GetEpochSeconds(epoch:Int) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| epoch | Int | epoch from 0 |
Return
| Type | Description |
|---|---|
| Float | seconds |
GetEpochs #
The number of finished epochs.
method : public : GetEpochs() ~ IntReturn
| Type | Description |
|---|---|
| Int | epochs |
GetError #
Why training stopped early, empty if it ran to the end.
method : public : GetError() ~ StringReturn
| Type | Description |
|---|---|
| String | the reason |
GetTotalSeconds #
Total wall-clock seconds of all epochs.
method : public : GetTotalSeconds() ~ FloatReturn
| Type | Description |
|---|---|
| Float | seconds |
GetTrainAccuracy #
Training accuracy of an epoch, 0.0 to 1.0.
method : public : GetTrainAccuracy(epoch:Int) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| epoch | Int | epoch from 0 |
Return
| Type | Description |
|---|---|
| Float | accuracy |
GetTrainLoss #
Mean training loss of an epoch.
method : public : GetTrainLoss(epoch:Int) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| epoch | Int | epoch from 0 |
Return
| Type | Description |
|---|---|
| Float | loss, 0.0 if there is no such epoch |
GetValidationAccuracy #
Validation accuracy after an epoch, 0.0 to 1.0.
method : public : GetValidationAccuracy(epoch:Int) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| epoch | Int | epoch from 0 |
Return
| Type | Description |
|---|---|
| Float | accuracy |
GetValidationLoss #
Validation loss after an epoch.
method : public : GetValidationLoss(epoch:Int) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| epoch | Int | epoch from 0 |
Return
| Type | Description |
|---|---|
| Float | loss |
SaveCsv #
Writes the CSV to a file.
method : public : SaveCsv(path:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| path | String | file to write |
Return
| Type | Description |
|---|---|
| Bool | true 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() ~ StringReturn
| Type | Description |
|---|---|
| String | the 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) ~ ResultTableParameters
| Name | Type | Description |
|---|---|---|
| title | String | table title |
Return
| Type | Description |
|---|---|
| ResultTable | the table |