Skip to main content

Hyperparameters

Configure your model's training behavior by setting hyperparameters, training parameters, and augmentation options. All parameters are set through the trainingObject after linking your model with the dataset

trainingObject = user.linkModelDataset('Dataset ID')

To see all current parameter settings, run trainingObject.getTrainingPlan(). To run consecutive experiments, overwrite parameters and re-start training with trainingObject.start().

info

You can refer to the TensorFlow Documentation for more information on TensorFlow augmentation parameters and the PyTorch Documentation for more information on PyTorch augmentation parameters.

Training Parameters

Basic training configuration parameters that control the fundamental aspects of your training process.

ParameterDescriptionDefaultExample
EpochsNumber of complete passes through the entire dataset10trainingObject.epochs(100)
CyclesNumber of complete passes through training and validation datasets1trainingObject.cycles(10)
Batch SizeNumber of samples processed at one time. Leverage but do not exceed the available computeDatatype dependent
16 in most cases
trainingObject.batchSize(16)
Validation SplitPercentage of dataset used for validation (0-1)Dataset dependent
20% in most cases
trainingObject.validation_split(0.2)

Core Hyperparameters

1. Optimizer

Controls how the model's parameters are updated during training. Supports different optimizers for TensorFlow and PyTorch. The default optimizer is SGD for both PyTorch and tensorflow.

Supported Optimizers:

  • TensorFlow: adam, rmsprop, sgd, adadelta, adagrad, adamax, nadam, ftrl
  • PyTorch: adam, rmsprop, sgd, adadelta, adagrad, adamax
trainingObject.optimizer('rmsprop')

2. Learning Rate

Controls the rate at which the model learns. Supports three different types:

TypeDescriptionFramework SupportExample
ConstantFixed learning rate throughout trainingTensorFlow, PyTorchtrainingObject.learningRate({'type': 'constant', 'value': 0.002})
AdaptiveLearning rate that changes based on scheduleTensorFlowtrainingObject.learningRateAdaptive({'type': 'adaptive', 'schedular': 'ExponentialDecay', 'decay_steps':1000, 'decay_rate':0.5})
CustomUser-defined learning rate functionTensorFlowtrainingObject.learningRateCustom({'type': 'custom', 'value': custom_function, 'epoch': 4})

Default: {'type': 'constant', 'value': 0.001}

  • Custom for TensorFlow: Set a custom learning rate function like the one below. Then call the method learningRateCustom method of trainingObject and pass the corresponding values:
    def custom_LearningRate_schedular(epoch):
    if epoch < 5:
    return 0.01
    else:
    return 0.01 * tf.math.exp(0.1 * (10 - epoch))
    trainingObject.learningRateCustom({'type': 'constant', 'value': custom_LearningRate_schedular, 'epoch': 4})

3. Loss Function

Defines how the model measures prediction errors. Supports standard and custom loss functions. It is implemented similarly to the built-in loss function in TensorFlow.

Supported Loss Functions:

  • TensorFlow: binary_crossentropy, categorical_crossentropy, mse, custom loss functions
  • PyTorch: crossentropy, mse, l1
# Standard loss function
trainingObject.lossFunction({'type': 'standard', 'value': 'categorical_crossentropy'})

# Custom loss function (TensorFlow only)
def custom_mse(y_true, y_pred):
# calculating squared difference between target and predicted values
loss = K.square(y_pred - y_true) # (batch_size, 2)

# multiplying the values with weights along batch dimension
loss = loss * [0.3, 0.7] # (batch_size, 2)

# summing both loss values along batch dimension
loss = K.sum(loss, axis=1) # (batch_size,)

return loss
trainingObject.lossFunctionCustom({'type': 'custom', 'value': custom_mse})

Default: {'type': 'standard', 'value': 'mse'}

Training Control

Layer Freezing

Specify which layers should remain unchanged during training:

trainingObject.layersFreeze(['conv1','fc1'])

Callbacks

Control training behavior with various callbacks:

CallbackPurposeParametersExample
Early StoppingStop training when metric stops improvingmetric, patiencetrainingObject.earlystopCallback('loss', 10)
Reduce LRReduce learning rate when metric plateausmetric, factor, patience, thresholdtrainingObject.reducelrCallback('loss', 0.1, 10, 0.0001)
Model CheckpointSave model weights at specific intervalsmetric, save_best_onlytrainingObject.modelCheckpointCallback('val_loss', True)
Terminate on NaNStop training if validation loss becomes NaNNonetrainingObject.terminateOnNaNCallback()

Data Augmentation for Image Data

Enhance your dataset with real-time image transformations. All parameters support both TensorFlow and PyTorch unless noted otherwise.

Geometric Transformations

ParameterDescriptionDefaultFramework SupportExample
rotation_rangeDegree range for random rotations. For example, if the rotation_range is set to 2, images will be rotated by a random degree between -2 and 20TensorFlow, PyTorchtrainingObject.rotation_range(2)
width_shift_rangeRange for horizontal shifts (float: fraction, int: pixels). If the value is a float less than 1, it represents a fraction of total width; otherwise it represents pixels. Integers represent pixel values from the interval (-width_shift_range, +width_shift_range)0.0TensorFlow, PyTorchtrainingObject.width_shift_range(0.1)
height_shift_rangeRange for vertical shifts (float: fraction, int: pixels). Works like width_shift_range0.0TensorFlow, PyTorchtrainingObject.height_shift_range(0.1)
shear_rangeShear intensity in degrees in counter-clockwise direction0.0TensorFlowtrainingObject.shear_range(0.2)
zoom_rangeRange for zooming (float or list). If the value is a float, then zoom range is defined as [1-zoom_range, 1+zoom_range]. If the value is a list, it represents the range of zoom0.0TensorFlow, PyTorchtrainingObject.zoom_range(0.1), trainingObject.zoom_range([0.2, 0.8])
horizontal_flipRandomly flip images horizontallyFalseTensorFlowtrainingObject.horizontal_flip(True)
vertical_flipRandomly flip images verticallyFalseTensorFlowtrainingObject.vertical_flip(True)

Color and Intensity Transformations

ParameterDescriptionDefaultFramework SupportExample
brightness_rangeRange for brightness shifts (tuple of floats)NoneTensorFlow, PyTorchtrainingObject.brightness_range((0.1,0.4))
channel_shift_rangeRange for random channel shifts0TensorFlow, PyTorch*trainingObject.channel_shift_range(0.4)
rescaleRescaling factor for pixel values (float)NoneTensorFlow, PyTorchtrainingObject.rescale(1.0/255.0)

*PyTorch: Only supported for RGB images

Normalization

ParameterDescriptionDefaultFramework SupportExample
samplewise_centerCenter each image by subtracting meanFalseTensorFlowtrainingObject.samplewise_center(True)
samplewise_std_normalizationStandardize each image by subtracting the mean and dividing by the standard deviation of pixel values. Calculated individuallyFalseTensorFlowtrainingObject.samplewise_std_normalization(True)

Other Parameters

ParameterDescriptionDefaultFramework SupportExample
fill_modeMethod for filling points outside boundaries. Supported for TensorFlow: "constant", "nearest", "reflect", "wrap". For PyTorch: "constant", "edge", "symmetric", "reflect", "wrap".'nearest'TensorFlow, PyTorchtrainingObject.fill_mode("nearest")
cvalFill value for points outside the image boundaries when fill_mode="constant"0.0TensorFlow, PyTorchtrainingObject.cval(0.3)
shuffleWhether to shuffle the dataTrueTensorFlow, PyTorchtrainingObject.shuffle(True)

LLM Parameters (Text Classification)

For text classification tasks in PyTorch, you can enable and configure LoRA (Low-Rank Adaptation) parameters:

# Enable LoRA first
trainingObject.enable_lora(True)

# Configure LoRA parameters (all parameters are optional)
trainingObject.set_lora_parameters(
q_lora=False, # Enable Q LoRA
lora_alpha=512, # Scaling factor
lora_dropout=0.05, # Dropout rate
lora_r=256 # Rank for LoRA layer
)
ParameterDescriptionTypeDefaultExample
lora_rRank for the LoRA layerPositive integer256lora_r=256
lora_alphaScaling factor alpha for LoRAPositive integer512lora_alpha=512
lora_dropoutDropout rate for LoRA layersFloat (0-1)0.05lora_dropout=0.05
q_loraEnable or disable Q LoRABooleanFalseq_lora=False

Note: LLM parameters are supported only for PyTorch.

Dataset Parameters (Optional)

Customize your dataset configuration and preprocessing options:

Dataset Customization

ParameterDescriptionExample
trainingClassesCustomize dataset by specifying samples per classtrainingObject.trainingClasses({'car': 30, 'person': 30})
imageTypeImage format: 'rgb' or 'grayscale'trainingObject.imageType('rgb')
seedSet global random seedtrainingObject.seed(True)

Need Help?

For more info about available functions and methods, call the help function in your notebook:

user.help()