How to …?

Change default configs

Edit deeptrain.util.configs.

  • Do not edit deeptrain.util._default_configs, this will break DeepTrain.
  • Arguments defined in TrainGenerator.__init__() will override those specified in the configs (the defaults have no overlaps), so no point in specifying them in configs.

Run examples

pip install deeptrain excludes data by default. To acquire, you can:

  1. Build data by running scripts in examples/preprocessing. Or,
  2. Clone repository and copy-paste examples/dir/data into the pip-installed deeptrain directory.

With the data you can run the .ipynb with Jupyter or equivalent .py scripts in IPython. Note for docs notebook examples, code isn’t exact, and excludes some formatting irrelevant the examples (e.g. many used os.environ['SCALEFIG'] = '.7').

Save train state

  1. Using TrainGenerator.save(), which saves:

    • TrainGenerator attributes
    • DataGenerator` (both) attributes
    • Model state (layer weights, optimizer weights, and/or architecture)
  2. Using TrainGenerator.checkpoint(), which saves what .save() saves, plus:

3. Saving behavior is configured for objects by respective attributes (defaults in_default_configs):

  • TrainGenerator: saveskip_list
  • DataGenerator (for each): saveskip_list
  • model: model_save_kw, model_save_weights_kw, optimizer_save_configs
  • Preprocessor (of each DataGenerator): saveskip_list

Example in Deeper into DeepTrain.

Load train state

1. Using TrainGenerator.load(), which may load everything saved via TrainGenerator.save() and TrainGenerator.checkpoint().

2. Loading behavior is configured for objects by respective attributes (defaults in_default_configs):

  • TrainGenerator: loadskip_list
  • DataGenerator (for each): loadskip_list
  • model: optimizer_load_configs
  • Preprocessor (of each DataGenerator): loadskip_list

Example in Deeper into DeepTrain.

Use custom train / evaluation function

Set fit_fn / eval_fn; see docs in TrainGenerator().