training_job_config
sleap_nn.config.training_job_config
¶
Serializable configuration classes for specifying all training job parameters.
These configuration classes are intended to specify all the parameters required to run a training job or perform inference from a serialized one.
They are explicitly not intended to implement any of the underlying functionality that they parametrize. This serves two purposes:
1. Parameter specification through simple attributes. These can be read/edited by a
human, as well as easily be serialized/deserialized to/from simple dictionaries
and YAML.
2. Decoupling from the implementation. This makes it easier to design functional
modules with attributes/parameters that contain objects that may not be easily
serializable or may implement additional logic that relies on runtime
information or other parameters.
In general, classes that implement the actual functionality related to these configuration classes should provide a classmethod for instantiation from the configuration class instances. This makes it easier to implement other logic not related to the high level parameters at creation time.
Conveniently, this format also provides a single location where all user-facing parameters are aggregated and documented for end users (as opposed to developers).
Classes:
Name | Description |
---|---|
TrainingJobConfig |
Configuration of a training job. |
Functions:
Name | Description |
---|---|
check_must_be_set |
Check that all required fields are set in the BackboneConfig and HeadConfig. |
verify_training_cfg |
Get sleap-nn training config from a DictConfig object. |
TrainingJobConfig
¶
Configuration of a training job.
Attributes:
Name | Type | Description |
---|---|---|
data_config |
DataConfig
|
Configuration options related to the training data. |
model_config |
ModelConfig
|
Configuration options related to the model architecture. |
trainer_config |
TrainerConfig
|
Configuration ooptions related to model training. |
outputs |
TrainerConfig
|
Configuration options related to outputs during training. |
name |
Optional[Text]
|
Optional name for this configuration profile. |
description |
Optional[Text]
|
Optional description of the configuration. |
sleap_nn_version |
Optional[Text]
|
Version of SLEAP that generated this configuration. |
filename |
Optional[Text]
|
Path to this config file if it was loaded from disk. |
Methods:
Name | Description |
---|---|
load_sleap_config |
Load a SLEAP configuration from a JSON file and convert it to OmegaConf. |
load_sleap_config_from_json |
Load a SLEAP configuration from a JSON string and convert it to OmegaConf. |
to_sleap_nn_cfg |
Convert the attrs class to OmegaConf object. |
Source code in sleap_nn/config/training_job_config.py
load_sleap_config(json_file_path)
classmethod
¶
Load a SLEAP configuration from a JSON file and convert it to OmegaConf.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cls
|
The class to instantiate with the loaded configuration. |
required | |
json_file_path
|
str
|
Path to a JSON file containing the SLEAP configuration. |
required |
Returns:
Type | Description |
---|---|
OmegaConf
|
An OmegaConf instance with the loaded configuration. |
Source code in sleap_nn/config/training_job_config.py
load_sleap_config_from_json(json_str)
classmethod
¶
Load a SLEAP configuration from a JSON string and convert it to OmegaConf.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cls
|
The class to instantiate with the loaded configuration. |
required | |
json_str
|
str
|
JSON-formatted string containing the SLEAP configuration. |
required |
Returns:
Type | Description |
---|---|
OmegaConf
|
An OmegaConf instance with the loaded configuration. |
Source code in sleap_nn/config/training_job_config.py
to_sleap_nn_cfg()
¶
Convert the attrs class to OmegaConf object.
check_must_be_set(config)
¶
Check that all required fields are set in the BackboneConfig and HeadConfig.
Source code in sleap_nn/config/training_job_config.py
verify_training_cfg(cfg)
¶
Get sleap-nn training config from a DictConfig object.