Shortcuts

lumin.nn.training package

Submodules

lumin.nn.training.fold_train module

lumin.nn.training.metric_logger module

lumin.nn.training.train module

lumin.nn.training.train.train_models(fy, n_models, bs, model_builder, n_epochs, patience=None, loss_is_meaned=True, cb_partials=None, eval_metrics=None, pred_cb=<class 'lumin.nn.callbacks.pred_handlers.PredHandler'>, train_on_weights=True, bulk_move=True, start_mode_id=0, live_fdbk=False, live_fdbk_first_only=False, live_fdbk_extra=True, live_fdbk_extra_first_only=False, savepath=Path('train_weights'), plot_settings=<lumin.plotting.plot_settings.PlotSettings object>)[source]

Main training method for Model. Trains a specified numer of models created by a ModelBuilder on data provided by a FoldYielder, and saves them to savepath.

Note, this does not return trained models, instead they are saved and must be loaded later. Instead this method returns results of model training. Each Model is trained on N-1 folds, for a FoldYielder with N folds, and the remaining fold is used as validation data.

Depending on the live_fdbk arguments, live plots of losses and other metrics may be shown during training, if running in Jupyter. Showing the live plot slightly slows down the training, but can help highlight problems without having to wait to the end. If not running in Jupyter, then losses are printed to the terminal.

Once training is finished, the state with the lowest validation loss is loaded, evaluated, and saved.

Parameters
  • fy (FoldYielder) – FoldYielder interfacing ot training data

  • n_models (int) – number of models to train

  • bs (int) – batch size. Number of data points per iteration

  • model_builder (ModelBuilder) – ModelBuilder creating the networks to train

  • n_epochs (int) – maximum number of epochs for which to train

  • patience (Optional[int]) – if not None, sets the number of epochs or cycles to train without decrease in validation loss before ending training (early stopping)

  • loss_is_meaned (bool) – if the batch loss value has been averaged over the number of elements in the batch, this should be true

  • cb_partials (Optional[List[partial]]) – optional list of functools.partial, each of which will a instantiate Callback when called

  • eval_metrics (Optional[Dict[str, EvalMetric]]) – list of instantiated EvalMetric. At the end of training, validation data and model predictions will be passed to each, and the results printed and saved

  • pred_cb (Callable[[], PredHandler]) – pred_cb: PredHandler callback to determin how predictions are computed. Default simply returns the model predictions. Other uses could be e.g. running argmax on a multiclass classifier

  • train_on_weights (bool) – If weights are present in training data, whether to pass them to the loss function during training

  • bulk_move (bool) – if true, will optimise for speed by using more RAM and VRAM

  • start_mode_id (int) – model ID at whcih to start training, i.e. if training was interupted, this can be set to resume training form the last model which was trained

  • live_fdbk (bool) – whether or not to show any live feedback at all during training (slightly slows down training, but helps spot problems)

  • live_fdbk_first_only (bool) – whether to only show live feedback for the first model trained (trade off between time and problem spotting)

  • live_fdbk_extra (bool) – whether to show extra information live feedback (further slows training)

  • live_fdbk_extra_first_only (bool) – whether to only show extra live feedback information for the first model trained (trade off between time and information)

  • savepath (Path) – path to to which to save model weights and results

  • plot_settings (PlotSettings) – PlotSettings class to control figure appearance

Return type

Tuple[List[Dict[str, float]], List[Dict[str, List[float]]], List[Dict[str, float]]]

Returns

  • results list of validation losses and other eval_metrics results, ordered by model training. Can be used to create an Ensemble.

  • histories list of loss histories, ordered by model training

  • cycle_losses if an AbsCyclicCallback was passed, lists validation losses at the end of each cycle, ordered by model training. Can be passed to Ensemble.

Module contents

Read the Docs v: v0.7.0
Versions
latest
stable
v0.7.0
v0.6.0
v0.5.1
v0.5.0
v0.4.0.1
v0.3.1
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.

Docs

Access comprehensive developer and user documentation for LUMIN

View Docs

Tutorials

Get tutorials for beginner and advanced researchers demonstrating many of the features of LUMIN

View Tutorials