Train construct

The train construct defines how to compile the model, how long to train the model, and initializes the dashboard to visualize the model's performance during training. It contains three blocks as shown in this example:

train:
    compile:
        optimizer = SGD: [lr = 0.001],
        loss = 'binary_crossentropy',
        metrics = ['accuracy'] ;
    run:
        epochs = 8 ;

    dashboard: ;
  • compile This component tells the compiler how to build the model. This component requires a comma separated list of two arguments, and takes an optional third, terminated by a semi-colon:

    The mandatory arguments are:

    • optimizer - The optimization algorithm to use. Neopulse® AI Studio provides access to all of the optimizers in the Keras library. The optimizer can be set in two ways:

      • optimizer = 'optimizer' - sets the optimizer with the default parameters.

      • optimizer = optimizer: [param1=value, ...] - sets the optimizer and allows the user to alter the default parameters.

      NOTE: the auto keyword may be used to let the oracle choose the optimizer.

    • loss - The loss function to use. NeoPulse® AI Studio provides access to all of the loss functions in the Keras library. Loss functions can be set:

      • loss = 'function_name'

      NOTE: the auto keyword may be used to let the oracle choose the loss function.

    • metrics OPTIONAL The default metric for NeoPulse® AI Studio is just the training loss. You can also track the accuracy of the model by setting: metrics = ['accuracy'] in the compile component.

    NOTE: You must specify an optimizer and a loss function, or ask the AI oracle to pick one by using the auto keyword.

  • run This component has two arguments (with their default values shown):

    • epochs = 1 Number of times to train on the data.
    • initial_epoch = 0 Epoch to start training (useful when retraining or fine-tuning an already trained model)
  • dashboard This component enables NeoPulse® AI Studio to provide visualization of model training using Tensorboard. It does not take any arguments at this time.

Example:

train:
    compile:
        optimizer = SGD: [lr = 0.001],
        loss = auto,
        metrics = ['accuracy'] ;
    run:
        epochs = 8 ;

    dashboard: ;

This example asks the AI oracle to choose the optimizer to minimize the binary_crossentropy of the model, track the accuracy of the model as well as the loss, and train eight times on the dataset.

NOTE: As of version 2.0, training with multiple GPUs is now supported. To train with multiple GPUs, simply add the key Ngpu and specify the number of GPUs to the train_opt construct, as shown below.

train Ngpu 2:

Limitations

At this time NML does not support user defined metrics.