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)".
CnnRuntime
Process-wide settings of the native layers and a seeded shuffle.
Operations
CudaDeviceCount # function
How many CUDA devices the optional GPU library found. The library (libobjk_ml_cuda, built apart from Objeck, see docs/AI.md) is loaded on the first call; without it, or without an NVIDIA GPU and driver, the answer is 0 and CudaStatus() says why.
function : CudaDeviceCount() ~ IntReturn
| Type | Description |
|---|---|
| Int | the device count, 0 when CUDA is unavailable |
CudaFreeMemory # function
The memory that is free on a CUDA device right now.
function : CudaFreeMemory(index:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| index | Int | device number |
Return
| Type | Description |
|---|---|
| Int | free megabytes, 0 when there is no such device |
CudaStatus # function
Why CUDA cannot be used.
function : CudaStatus() ~ StringReturn
| Type | Description |
|---|---|
| String | the reason, or an empty string when a CUDA device is available |
GetDevices # function
The devices a model can be placed on, as the names SetDevice takes: "cpu", then "cuda:0", "cuda:1" ... with the GPU's name and memory.
function : GetDevices() ~ String[]Return
| Type | Description |
|---|---|
| String | the descriptions, "cpu" first |
GetThreads # function
The number of threads the layers use.
function : GetThreads() ~ IntReturn
| Type | Description |
|---|---|
| Int | thread count |
HasCuda # function
Is there a CUDA device a model can run on?
function : HasCuda() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if so |
Permutation # function
A seeded shuffle of 0 .. n - 1 (Fisher-Yates), the same on every platform.
function : Permutation(n:Int, seed:Int) ~ Int[]Parameters
| Name | Type | Description |
|---|---|---|
| n | Int | how many values, 1 or more |
| seed | Int | shuffle seed |
Return
| Type | Description |
|---|---|
| Int | the permutation, or Nil when n is below 1 |
SetThreads # function
Sets how many threads the layers use (the batch is spread over them, one sample per task). The setting is process-wide: every model, on every Objeck thread, shares the one pool. The default is the number of hardware threads, at most 8, which differs between machines; a run repeats bit for bit only at a fixed thread count, so set it (to 1 or any fixed number) for a result that must be the same on another machine.
function : SetThreads(count:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| count | Int | threads, 1 to 64 |
Return
| Type | Description |
|---|---|
| Int | the thread count now in force |