What is validation loss?
Validation loss measures how well your model performs on data it has never seen during training. By holding out a small portion of your dataset and evaluating it periodically, you can detect overfitting — the point at which the model memorizes the training images instead of learning general concepts. Without validation loss you only have training loss, which will decrease continuously regardless of whether the model is actually improving or just memorizing. When you see training loss still falling but validation loss rising, the model has started to overfit and you should stop training or reduce your learning rate.Every validation run uses the same random seed for noise generation and timestep selection. This makes the metric deterministic: any change in the validation loss reflects a real change in model weights, not random variance in the evaluation process.
How to enable validation
There are two ways to set up a validation split. The dataset config TOML approach is recommended because it gives you precise control over which images are used for validation.- Dataset config TOML (recommended)
- Command-line argument
Add a validation subset to your dataset Use a fraction of a subset for validation by setting The TOML setting takes precedence over the command-line
.toml file by setting validation_split on one or more [[datasets.subsets]] entries.Use an entire directory for validation by setting validation_split = 1.0:validation_split to a value between 0.0 and 1.0:--validation_split argument.Configuration options
| Argument | TOML key | Description |
|---|---|---|
--validation_split <f> | validation_split | Fraction of data to hold out for validation. The command-line argument applies globally; the TOML key applies per subset. |
--validate_every_n_steps <n> | — | Run a validation pass every N training steps. |
--validate_every_n_epochs <n> | — | Run a validation pass every N epochs. Defaults to once per epoch when not specified. |
--max_validation_steps <n> | — | Cap the number of validation batches per evaluation pass. Useful if your validation set is large. Omit to use the entire validation set. |
--validation_seed <n> | validation_seed | Seed for validation dataloader shuffling. Falls back to the main training --seed when not set. |
Complete example
Prepare your dataset config
Create a
dataset_config.toml that separates training and validation images:Run training
Launch training with logging enabled so you can view the validation metric in TensorBoard:
Reading the results
The validation loss is logged to TensorBoard (or Weights & Biases if you use--log_with=wandb) as loss/validation. A healthy training run looks like this:
- Training loss decreases steadily over time.
- Validation loss also decreases, tracking training loss loosely.
- If validation loss starts rising while training loss keeps falling, the model is overfitting. Consider stopping training, reducing the learning rate, or increasing
validation_splitto give the model more validation signal.
