Configuring Models
Trains is now ClearML
This documentation applies to the legacy Trains versions. For the latest documentation, see ClearML.
The model_config.py example demonstrates configuring a model and defining class label enumeration. Connect the configuration and class label enumeration to a Task and, once connected, Trains tracks any changes to them. When Trains stores a model, in any framework, Trains stores the configuration and class label enumeration with it.
When the script runs, it creates an experiment named Model configuration example
, which is associated with the examples
project.
Configuring models
Using a configuration file
Connect a configuration file to a Task by reading the file, and then calling the Task.connect_configuration method with the file.
# Connect a local configuration file
config_file = os.path.join('data_samples', 'sample.json')
config_file = task.connect_configuration(config_file)
Trains reports the configuration in the Trains Web (UI), experiment details, ARTIFACTS tab, Input Model area. See the image in the next section.
Configuration dictionary
Connect a configuration dictionary to a Task by creating a dictionary, and then calling the Task.connect_configuration method with the dictionary. After the configuration is connected, Trains tracks changes to it.
model_config_dict = {
'value': 13.37,
'dict': {'sub_value': 'string', 'sub_integer': 11},
'list_of_ints': [1, 2, 3, 4],
}
model_config_dict = task.connect_configuration(model_config_dict)
# We now update the dictionary after connecting it, and the changes will be tracked as well.
model_config_dict['new value'] = 10
model_config_dict['value'] *= model_config_dict['new value']
Trains reports the configuration in the Trains Web (UI), experiment details, ARTIFACTS tab, Input Model area.
Class label enumeration
Connect a class enumeration dictionary by creating the dictionary, and then calling the Task.connect_label_enumeration method with the dictionary.
# store the label enumeration of the training model
labels = {'background': 0, 'cat': 1, 'dog': 2}
task.connect_label_enumeration(labels)
Trains reports the configuration in the Trains Web (UI), models details, LABELS tab.
This example does not store a model, however.