Train

Training is handled by the built-in Training phase from SleePyPhases. The project configuration, a CSV training log, and model checkpoints are stored in the log folder (log-path default ./logs) for reproducibility and later analysis. The traning path follows

Running training

phases run Training

The Training phase depends on BuildDataset which depends on Extract. If those outputs are not cached, the framework runs them first.

Config keys

All training parameters live under trainingParameter:

trainingParameter:
  maxEpochs: 100
  lr: 0.001                       # initial learning rate
  batchSize: 32
  optimizer: adams                 # 'adams' (Adam), 'sgd', 'rmsprop'
  stopAfterNotImproving: 10       # early stopping patience (epochs)
  validationMetrics:
    - kappa                        # metric(s) used for model selection
  cyclicLearningRate: false        # enable cyclic LR schedule
  findCyclicLearningRate: false    # run LR range finder before training
Key Type Default Description
trainingParameter.maxEpochs int 0 Maximum number of training epochs
trainingParameter.lr float 0.001 Initial learning rate
trainingParameter.batchSize int 32 Training batch size
trainingParameter.optimizer str adams Optimizer: adams, sgd, rmsprop, can also be set programmatically
trainingParameter.stopAfterNotImproving int 0 Early stopping: stop after N epochs without improvement
trainingParameter.validationMetrics list[str] ["acc"] Metrics evaluated on validation fold for model selection
trainingParameter.cyclicLearningRate bool false Use cyclic learning rate (CLR) schedule
trainingParameter.findCyclicLearningRate bool false Run LR range finder sweep before training

Validation metrics

The model checkpoint saved to disk is the epoch that maximises the first entry in validationMetrics. Available metrics are those registered in Scorer (e.g. kappa, accuracy, f1, auprc). For a full list see the Scorer documentation and for integrating custom metrics see Custom Metrics.

Outputs

After training completes, Training registers three data artifacts:

  • modelState — path to the best checkpoint (.pt or framework-equivalent)
  • trainingConfig — the config snapshot that the model depends on (for reproducibility)
  • projectConfig — the full project config snapshot (for reproducibility)

Cross-validation

With dataversion.folds: 5, the training will run all fold sequentially. You can start the training for a specific fold using the CLI --set flag to override config values at runtime:

phases run  --set startFold=0 --set endFold=1 Training
phases run  --set startFold=1 --set endFold=2 Training

The Training phase loads the weights before the training loop begins.

Next step

Evaluate — compute metrics and generate evaluation reports