Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions join-use-case/hyperparameters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ description: "Configure your model's training behavior by setting hyperparameter

## Training Parameters

All parameters are set through the `trainingObject` after linking your model with the dataset.
All parameters are set through the `training` after linking your model with the dataset.


```python
trainingObject = user.linkModelDataset('Dataset ID')
training = user.link_model_dataset('Dataset ID')
```

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

<Info>
You can refer to the [TensorFlow Documentation](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/ImageDataGenerator) for more information on TensorFlow augmentation parameters and the [PyTorch Documentation](https://albumentations.ai/docs/examples/pytorch-classification/) for more information on PyTorch augmentation parameters.
Expand All @@ -23,10 +23,10 @@ Basic training configuration parameters that control the fundamental aspects of

| Parameter | Description | Default | Example |
|-----------|-------------|---------|---------|
| **Epochs** | Number of complete passes through the entire dataset | 10 | `trainingObject.epochs(100)` |
| **Cycles** | Number of complete passes through training and validation datasets | 1 | `trainingObject.cycles(10)` |
| **Epochs** | Number of complete passes through the entire dataset | 10 | `training.epochs(100)` |
| **Cycles** | Number of complete passes through training and validation datasets | 1 | `training.cycles(10)` |
| **Batch Size** | Number of samples processed at one time. Set automatically from the `batch_size` variable in your model file | Datatype dependent <br></br> 16 in most cases | Set via `batch_size = 16` in your model `.py` file |
| **Validation Split** | Percentage of dataset used for validation (0-1) | Dataset dependent <br></br> 20% in most cases | `trainingObject.validation_split(0.2)` |
| **Validation Split** | Percentage of dataset used for validation (0-1) | Dataset dependent <br></br> 20% in most cases | `training.validation_split(0.2)` |

## Core Hyperparameters

Expand All @@ -39,7 +39,7 @@ Controls how the model's parameters are updated during training. Supports differ
- **PyTorch**: adam, rmsprop, sgd, adadelta, adagrad, adamax

```python
trainingObject.optimizer('rmsprop')
training.optimizer('rmsprop')
```

### 2. Learning Rate
Expand All @@ -48,20 +48,20 @@ Controls the rate at which the model learns. Supports three different types:

| Type | Description | Framework Support | Example |
|------|-------------|-------------------|---------|
| **Constant** | Fixed learning rate throughout training | TensorFlow, PyTorch | `trainingObject.learningRate({'type': 'constant', 'value': 0.002})` |
| **Adaptive** | Learning rate that changes based on schedule | TensorFlow | `trainingObject.learningRate({'type': 'adaptive', 'value': {'decay_rate': 0.9, 'decay_steps': 100, 'initial_learning_rate': 0.1, 'scheduler': 'ExponentialDecay'}})` |
| **Custom** | User-defined learning rate function | TensorFlow | `trainingObject.learningRate({'type': 'custom', 'value': {'name': custom_function, 'epoch': 5}})` |
| **Constant** | Fixed learning rate throughout training | TensorFlow, PyTorch | `training.learning_rate({'type': 'constant', 'value': 0.002})` |
| **Adaptive** | Learning rate that changes based on schedule | TensorFlow | `training.learning_rate({'type': 'adaptive', 'value': {'decay_rate': 0.9, 'decay_steps': 100, 'initial_learning_rate': 0.1, 'scheduler': 'ExponentialDecay'}})` |
| **Custom** | User-defined learning rate function | TensorFlow | `training.learning_rate({'type': 'custom', 'value': {'name': custom_function, 'epoch': 5}})` |

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

* **Custom for TensorFlow**: Define a custom learning rate function, then pass it via `learningRate()` with `type: 'custom'`:
* **Custom for TensorFlow**: Define a custom learning rate function, then pass it via `learning_rate()` with `type: 'custom'`:
```python
def custom_LearningRate_scheduler(epoch):
if epoch < 5:
return 0.01
else:
return 0.01 * tf.math.exp(0.1 * (10 - epoch))
trainingObject.learningRate({'type': 'custom', 'value': {'name': custom_LearningRate_scheduler, 'epoch': 5}})
training.learning_rate({'type': 'custom', 'value': {'name': custom_LearningRate_scheduler, 'epoch': 5}})
```


Expand All @@ -75,7 +75,7 @@ Defines how the model measures prediction errors. Supports standard and custom l

```python
# Standard loss function
trainingObject.lossFunction({'type': 'standard', 'value': 'categorical_crossentropy'})
training.loss_function({'type': 'standard', 'value': 'categorical_crossentropy'})

# Custom loss function (TensorFlow only)
def custom_mse(y_true, y_pred):
Expand All @@ -89,7 +89,7 @@ def custom_mse(y_true, y_pred):
loss = K.sum(loss, axis=1) # (batch_size,)

return loss
trainingObject.lossFunction({'type': 'custom', 'value': custom_mse})
training.loss_function({'type': 'custom', 'value': custom_mse})
```
**Default:** `{'type': 'standard', 'value': 'mse'}`

Expand All @@ -100,7 +100,7 @@ trainingObject.lossFunction({'type': 'custom', 'value': custom_mse})
Specify which layers should remain unchanged during training (TensorFlow only):

```python
trainingObject.layersFreeze(['conv1','fc1'])
training.layers_freeze(['conv1','fc1'])
```

<Info>
Expand All @@ -113,10 +113,10 @@ Control training behavior with various callbacks:

| Callback | Purpose | Parameters | Example |
|----------|---------|------------|---------|
| **Early Stopping** | Stop training when metric stops improving | metric, patience | `trainingObject.earlystopCallback('loss', 10)` |
| **Reduce LR** | Reduce learning rate when metric plateaus | metric, factor, patience, threshold | `trainingObject.reducelrCallback('loss', 0.1, 10, 0.0001)` |
| **Model Checkpoint** | Save model weights at specific intervals | metric, save_best_only | `trainingObject.modelCheckpointCallback('val_loss', True)` |
| **Terminate on NaN** | Stop training if validation loss becomes NaN | None | `trainingObject.terminateOnNaNCallback()` |
| **Early Stopping** | Stop training when metric stops improving | metric, patience | `training.early_stop_callback('loss', 10)` |
| **Reduce LR** | Reduce learning rate when metric plateaus | metric, factor, patience, threshold | `training.reduce_lr_callback('loss', 0.1, 10, 0.0001)` |
| **Model Checkpoint** | Save model weights at specific intervals | metric, save_best_only | `training.model_checkpoint_callback('val_loss', True)` |
| **Terminate on NaN** | Stop training when a NaN loss is encountered | None | `training.terminate_on_nan_callback()` |



Expand All @@ -129,49 +129,49 @@ Enhance your dataset with real-time image transformations. All parameters suppor

| Parameter | Description | Default | Framework Support | Example |
|-----------|-------------|---------|-------------------|---------|
| **rotation_range** | Degree 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 2 | 0 | TensorFlow, PyTorch | `trainingObject.rotation_range(2)` |
| **width_shift_range** | Range 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.0 | TensorFlow, PyTorch | `trainingObject.width_shift_range(0.1)` |
| **height_shift_range** | Range for vertical shifts (float: fraction, int: pixels). Works like width_shift_range | 0.0 | TensorFlow, PyTorch | `trainingObject.height_shift_range(0.1)` |
| **shear_range** | Shear intensity in degrees in counter-clockwise direction | 0.0 | TensorFlow | `trainingObject.shear_range(0.2)` |
| **zoom_range** | Range 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 zoom | 0.0 | TensorFlow, PyTorch | `trainingObject.zoom_range(0.1)`, `trainingObject.zoom_range([0.2, 0.8])` |
| **horizontal_flip** | Randomly flip images horizontally | False | TensorFlow | `trainingObject.horizontal_flip(True)` |
| **vertical_flip** | Randomly flip images vertically | False | TensorFlow | `trainingObject.vertical_flip(True)` |
| **rotation_range** | Degree 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 2 | 0 | TensorFlow, PyTorch | `training.rotation_range(2)` |
| **width_shift_range** | Range 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.0 | TensorFlow, PyTorch | `training.width_shift_range(0.1)` |
| **height_shift_range** | Range for vertical shifts (float: fraction, int: pixels). Works like width_shift_range | 0.0 | TensorFlow, PyTorch | `training.height_shift_range(0.1)` |
| **shear_range** | Shear intensity in degrees in counter-clockwise direction | 0.0 | TensorFlow | `training.shear_range(0.2)` |
| **zoom_range** | Range 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 zoom | 0.0 | TensorFlow, PyTorch | `training.zoom_range(0.1)`, `training.zoom_range([0.2, 0.8])` |
| **horizontal_flip** | Randomly flip images horizontally | False | TensorFlow | `training.horizontal_flip(True)` |
| **vertical_flip** | Randomly flip images vertically | False | TensorFlow | `training.vertical_flip(True)` |

### Color and Intensity Transformations

| Parameter | Description | Default | Framework Support | Example |
|-----------|-------------|---------|-------------------|---------|
| **brightness_range** | Range for brightness shifts (tuple of floats) | None | TensorFlow, PyTorch | `trainingObject.brightness_range((0.1,0.4))` |
| **channel_shift_range** | Range for random channel shifts | 0 | TensorFlow, PyTorch* | `trainingObject.channel_shift_range(0.4)` |
| **rescale** | Rescaling factor for pixel values (float) | None | TensorFlow, PyTorch | `trainingObject.rescale(1.0/255.0)` |
| **brightness_range** | Range for brightness shifts (tuple of floats) | None | TensorFlow, PyTorch | `training.brightness_range((0.1,0.4))` |
| **channel_shift_range** | Range for random channel shifts | 0 | TensorFlow, PyTorch* | `training.channel_shift_range(0.4)` |
| **rescale** | Rescaling factor for pixel values (float) | None | TensorFlow, PyTorch | `training.rescale(1.0/255.0)` |

*PyTorch: Only supported for RGB images

### Normalization

| Parameter | Description | Default | Framework Support | Example |
|-----------|-------------|---------|-------------------|---------|
| **samplewise_center** | Center each image by subtracting mean | False | TensorFlow | `trainingObject.samplewise_center(True)` |
| **samplewise_std_normalization** | Standardize each image by subtracting the mean and dividing by the standard deviation of pixel values. Calculated individually | False | TensorFlow | `trainingObject.samplewise_std_normalization(True)` |
| **samplewise_center** | Center each image by subtracting mean | False | TensorFlow | `training.samplewise_center(True)` |
| **samplewise_std_normalization** | Standardize each image by subtracting the mean and dividing by the standard deviation of pixel values. Calculated individually | False | TensorFlow | `training.samplewise_std_normalization(True)` |

### Other Parameters

| Parameter | Description | Default | Framework Support | Example |
|-----------|-------------|---------|-------------------|---------|
| **fill_mode** | Method for filling points outside boundaries. Supported for TensorFlow: "constant", "nearest", "reflect", "wrap". For PyTorch: "constant", "edge", "symmetric", "reflect", "wrap". | 'constant' | TensorFlow, PyTorch | `trainingObject.fill_mode("nearest")` |
| **cval** | Fill value for points outside the image boundaries when fill_mode="constant" | 0.0 | TensorFlow, PyTorch | `trainingObject.cval(0.3)` |
| **shuffle** | Whether to shuffle the data | True | TensorFlow, PyTorch | `trainingObject.shuffle(True)` |
| **fill_mode** | Method for filling points outside boundaries. Supported for TensorFlow: "constant", "nearest", "reflect", "wrap". For PyTorch: "constant", "edge", "symmetric", "reflect", "wrap". | 'constant' | TensorFlow, PyTorch | `training.fill_mode("nearest")` |
| **cval** | Fill value for points outside the image boundaries when fill_mode="constant" | 0.0 | TensorFlow, PyTorch | `training.cval(0.3)` |
| **shuffle** | Whether to shuffle the data | True | TensorFlow, PyTorch | `training.shuffle(True)` |

## LLM Parameters (Text Classification)

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

```python
# Enable LoRA first
trainingObject.enable_lora(True)
training.enable_lora(True)

# Configure LoRA parameters (positional arguments: lora_r, lora_alpha, lora_dropout, q_lora)
trainingObject.set_lora_parameters(256, 512, 0.05, False)
training.set_lora_parameters(256, 512, 0.05, False)
```

| Parameter | Description | Type | Default | Example |
Expand All @@ -191,9 +191,9 @@ Customize your dataset configuration and preprocessing options:

| Parameter | Description | Example |
|-----------|-------------|---------|
| **trainingClasses** | Customize dataset by specifying samples per class | `trainingObject.trainingClasses({'car': 30, 'person': 30})` |
| **dataType** | Image format: 'rgb' or 'grayscale' | `trainingObject.dataType('rgb')` |
| **seed** | Set global random seed | `trainingObject.seed(True)` |
| **training_classes** | Customize dataset by specifying samples per class | `training.training_classes({'car': 30, 'person': 30})` |
| **data_type** | Image format: 'rgb' or 'grayscale' | `training.data_type('rgb')` |
| **seed** | Set global random seed | `training.seed(True)` |


---
Expand Down
25 changes: 15 additions & 10 deletions join-use-case/start-training.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ Then, install requirements:

```bash
python -m pip install --upgrade pip
pip install tracebloc_package

# Install with the extra that matches your framework:
pip install "tracebloc_package[pytorch]"
# pip install "tracebloc_package[tensorflow]"
# pip install "tracebloc_package[sklearn]"
# pip install "tracebloc_package[all]" # legacy behaviour — all frameworks
```

## Install and Launch Jupyter Notebook
Expand Down Expand Up @@ -149,7 +154,7 @@ In case of multiple uploads, only the most recently uploaded model will be linke
Upload the model to the use case workspace from your notebook:

```python
user.uploadModel("../../model-zoo/model_zoo/<task>/<framework>/model.py")
user.upload_model("../../model-zoo/model_zoo/<task>/<framework>/model.py")
```

For details on model code formats, mandatory variables per framework, and pre-trained weights, see [Customize Models](/join-use-case/model-optimization).
Expand All @@ -159,7 +164,7 @@ For details on model code formats, mandatory variables per framework, and pre-tr
Navigate to the use case and copy the "Training Dataset ID" at the center of the use case pane and enter it to establish the link

```python
trainingObject = user.linkModelDataset('Dataset ID')
training = user.link_model_dataset('Dataset ID')
```

You should get "Assignment successful!" and the dataset parameters.
Expand All @@ -170,14 +175,14 @@ Set the experiment name and configure hyperparameters.

```python
# Set experiment name
trainingObject.experimentName("My Experiment")
training.experiment_name("My Experiment")

# Set training parameters
trainingObject.epochs(10)
training.epochs(10)
...

# Get training plan
trainingObject.getTrainingPlan()
training.get_training_plan()
```

Get the training plan to check settings before you start the training. For a detailed list of all hyperparameter options, see [Hyperparameters](/join-use-case/hyperparameters).
Expand All @@ -186,10 +191,10 @@ For classical, non federated and non gradient descent-based machine learning alg

```python
# Set training parameters
trainingObject.epochs(1)
training.epochs(1)

# Set federated learning cycles = 1
trainingObject.cycles(1)
training.cycles(1)

```

Expand All @@ -198,13 +203,13 @@ trainingObject.cycles(1)
To send the model to the workspace infrastructure and start training on the training data, run:

```python
trainingObject.start()
training.start()
```

Go to the [tracebloc website](https://ai.tracebloc.io/my-use-cases) and your use case, then navigate to the "Training/Finetuning" tab you will see your experiment. Monitor the training process hover over the learning curves to check the performance at specific epochs and cycles.

<Info>
If you want to run a second experiment, overwrite parameters and re-start training with `trainingObject.start()`.
If you want to run a second experiment, overwrite parameters and re-start training with `training.start()`.
</Info>

### Pause, Re-Start and Stop:
Expand Down
Loading