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)".
Augmentation
The random changes applied to a TRAINING image as it is loaded: a horizontal flip, a rotation by a small random angle (bilinear, zeros outside) and a brightness factor (the pixels are multiplied and clipped to 0 .. 1). Each fires with its own probability. Whether it fires, and its value, depend only on the seed and the image's position in the epoch, so a run repeats exactly.
Example
aug := Augmentation->New();
aug->SetFlip(0.5); # half the images are mirrored
aug->SetRotation(0.3, 10.0); # 30% are turned by up to +-10 degrees
aug->SetBrightness(0.3, 0.8, 1.2); # 30% are scaled by 0.8 .. 1.2Operations
IsEnabled #
Is any augmentation switched on?
method : public : IsEnabled() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if so |
SetBrightness #
Brightness: the pixels are multiplied by a factor drawn uniformly from min_factor .. max_factor, then clipped to 0 .. 1.
method : public : SetBrightness(probability:Float, min_factor:Float, max_factor:Float) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| probability | Float | chance for each image, 0.0 to 1.0 |
| min_factor | Float | the smallest factor, above 0 |
| max_factor | Float | the largest factor |
SetFlip #
Horizontal flip.
method : public : SetFlip(probability:Float) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| probability | Float | chance for each image, 0.0 to 1.0 |