vis4d.config.typing¶
Type definitions for configuration files.
Classes
|
Configuration for a data set. |
|
Configuration for an experiment. |
|
Parameters for an experiment. |
|
Configuration for a learning rate scheduler. |
|
Configuration for an optimizer. |
Parameter group config. |
|
|
Configuration for a parameter sweep. |
- class DataConfig(initial_dictionary=None, type_safe=True, convert_dict=True)[source]¶
Configuration for a data set.
This data object is used to configure the training and test data of an experiment. In particular, the train_dataloader and test_dataloader need to be config dicts that can be instantiated as a dataloader.
- train_dataloader¶
Configuration for the training dataloader.
- Type:
ConfigDict
- test_dataloader¶
Configuration for the test dataloader.
- Type:
ConfigDict
Example
>>> from vis4d.config.types import DataConfig >>> from vis4d.zoo.base import class_config >>> from my_package.data import MyDataLoader >>> cfg = DataConfig() >>> cfg.train_dataloader = class_config(MyDataLoader, ...)
Creates an instance of ConfigDict.
Warning: In most cases, this faithfully reproduces the reference structure of initial_dictionary, even if initial_dictionary is self-referencing. However, unexpected behavior occurs if self-references are contained within list, tuple, or custom types. For example:
d = {} d['a'] = d d['b'] = [d] cd = ConfigDict(d) cd.a # refers to cd, type ConfigDict. Expected behavior. cd.b # refers to d, type dict. Unexpected behavior.
Warning: FieldReference values may be changed. If initial_dictionary contains a FieldReference with a value of type dict or FrozenConfigDict, that value is converted to ConfigDict.
- Parameters:
initial_dictionary (
Optional
[Mapping
[str
,Any
]]) –May be one of the following:
1) dict. In this case, all values of initial_dictionary that are dictionaries are also be converted to ConfigDict. However, dictionaries within values of non-dict type are untouched.
2) ConfigDict. In this case, all attributes are uncopied, and only the top-level object (self) is re-addressed. This is the same behavior as Python dict, list, and tuple.
3) FrozenConfigDict. In this case, initial_dictionary is converted to a ConfigDict version of the initial dictionary for the FrozenConfigDict (reversing any mutability changes FrozenConfigDict made).
type_safe (
bool
) – If set to True, once an attribute value is assigned, its type cannot be overridden without .ignore_type() context manager (default: True).convert_dict (
bool
) – If set to True, all dict used as value in the ConfigDict will automatically be converted to ConfigDict (default: True).
- class ExperimentConfig(initial_dictionary=None, type_safe=True, convert_dict=True)[source]¶
Configuration for an experiment.
This data object is used to configure an experiment. It contains the minimal required configuration to run an experiment. In particular, the data, model, optimizers, and loss need to be config dicts that can be instantiated as a data set, model, optimizer, and loss function, respectively.
- work_dir¶
The working directory for the experiment.
- Type:
str | FieldReference
- experiment_name¶
The name of the experiment.
- Type:
str | FieldReference
- timestamp¶
The timestamp of the experiment.
- Type:
str | FieldReference
- version¶
The version of the experiment.
- Type:
str | FieldReference
- output_dir¶
The output directory for the experiment.
- Type:
str | FieldReference
- seed¶
The random seed for the experiment.
- Type:
int | FieldReference
- log_every_n_steps¶
The number of steps after which the logs should be written.
- Type:
int | FieldReference
- use_tf32¶
Whether to use tf32.
- Type:
bool | FieldReference
- benchmark¶
Whether to enable benchmarking.
- Type:
bool | FieldReference
- params¶
Configuration for the experiment parameters.
- Type:
- data¶
Configuration for the dataset.
- Type:
- model¶
Configuration for the model.
- Type:
FieldConfigDictOrRef
- loss¶
Configuration for the loss function.
- Type:
FieldConfigDictOrRef
- optimizers¶
Configuration for the optimizers.
- Type:
list[OptimizerConfig]
- data_connector¶
Configuration for the data connector.
- Type:
FieldConfigDictOrRef
- callbacks¶
Configuration for the callbacks which are used in the engine.
- Type:
list[FieldConfigDictOrRef]
Creates an instance of FieldConfigDict.
- Parameters:
initial_dictionary (
Optional
[Mapping
[str
,Any
]]) –May be one of the following:
1) dict. In this case, all values of initial_dictionary that are dictionaries are also be converted to ConfigDict. However, dictionaries within values of non-dict type are untouched.
2) ConfigDict. In this case, all attributes are uncopied, and only the top-level object (self) is re-addressed. This is the same behavior as Python dict, list, and tuple.
3) FrozenConfigDict. In this case, initial_dictionary is converted to a ConfigDict version of the initial dictionary for the FrozenConfigDict (reversing any mutability changes FrozenConfigDict made).
type_safe (
bool
) – If set to True, once an attribute value is assigned, its type cannot be overridden without .ignore_type() context manager.convert_dict (
bool
) – If set to True, all dict used as value in the ConfigDict will automatically be converted to ConfigDict.
- class ExperimentParameters(initial_dictionary=None, type_safe=True, convert_dict=True)[source]¶
Parameters for an experiment.
- samples_per_gpu¶
Number of samples per GPU.
- Type:
int
- workers_per_gpu¶
Number of workers per GPU.
- Type:
int
Creates an instance of FieldConfigDict.
- Parameters:
initial_dictionary (
Optional
[Mapping
[str
,Any
]]) –May be one of the following:
1) dict. In this case, all values of initial_dictionary that are dictionaries are also be converted to ConfigDict. However, dictionaries within values of non-dict type are untouched.
2) ConfigDict. In this case, all attributes are uncopied, and only the top-level object (self) is re-addressed. This is the same behavior as Python dict, list, and tuple.
3) FrozenConfigDict. In this case, initial_dictionary is converted to a ConfigDict version of the initial dictionary for the FrozenConfigDict (reversing any mutability changes FrozenConfigDict made).
type_safe (
bool
) – If set to True, once an attribute value is assigned, its type cannot be overridden without .ignore_type() context manager.convert_dict (
bool
) – If set to True, all dict used as value in the ConfigDict will automatically be converted to ConfigDict.
- class LrSchedulerConfig(initial_dictionary=None, type_safe=True, convert_dict=True)[source]¶
Configuration for a learning rate scheduler.
- scheduler¶
Configuration for the learning rate scheduler.
- Type:
ConfigDict
- begin¶
Begin epoch.
- Type:
int
- end¶
End epoch.
- Type:
int
- epoch_based¶
Whether the learning rate scheduler is epoch based or step based.
- Type:
bool
- convert_epochs_to_steps¶
Whether to convert the begin and end for a step based scheduler to steps automatically based on length of train dataloader. Enables users to set the iteration breakpoints as epochs. Defaults to False.
- Type:
bool
- convert_attributes¶
List of attributes in the scheduler that should be converted to steps. Defaults to None.
- Type:
list[str] | None
Creates an instance of ConfigDict.
Warning: In most cases, this faithfully reproduces the reference structure of initial_dictionary, even if initial_dictionary is self-referencing. However, unexpected behavior occurs if self-references are contained within list, tuple, or custom types. For example:
d = {} d['a'] = d d['b'] = [d] cd = ConfigDict(d) cd.a # refers to cd, type ConfigDict. Expected behavior. cd.b # refers to d, type dict. Unexpected behavior.
Warning: FieldReference values may be changed. If initial_dictionary contains a FieldReference with a value of type dict or FrozenConfigDict, that value is converted to ConfigDict.
- Parameters:
initial_dictionary (
Optional
[Mapping
[str
,Any
]]) –May be one of the following:
1) dict. In this case, all values of initial_dictionary that are dictionaries are also be converted to ConfigDict. However, dictionaries within values of non-dict type are untouched.
2) ConfigDict. In this case, all attributes are uncopied, and only the top-level object (self) is re-addressed. This is the same behavior as Python dict, list, and tuple.
3) FrozenConfigDict. In this case, initial_dictionary is converted to a ConfigDict version of the initial dictionary for the FrozenConfigDict (reversing any mutability changes FrozenConfigDict made).
type_safe (
bool
) – If set to True, once an attribute value is assigned, its type cannot be overridden without .ignore_type() context manager (default: True).convert_dict (
bool
) – If set to True, all dict used as value in the ConfigDict will automatically be converted to ConfigDict (default: True).
- class OptimizerConfig(initial_dictionary=None, type_safe=True, convert_dict=True)[source]¶
Configuration for an optimizer.
- optimizer¶
Configuration for the optimizer.
- Type:
ConfigDict
- lr_scheduler¶
Configuration for the learning rate scheduler.
- Type:
list[LrSchedulerConfig] | None
- param_groups¶
Configuration for the parameter groups.
- Type:
list[ParamGroupCfg] | None
Creates an instance of ConfigDict.
Warning: In most cases, this faithfully reproduces the reference structure of initial_dictionary, even if initial_dictionary is self-referencing. However, unexpected behavior occurs if self-references are contained within list, tuple, or custom types. For example:
d = {} d['a'] = d d['b'] = [d] cd = ConfigDict(d) cd.a # refers to cd, type ConfigDict. Expected behavior. cd.b # refers to d, type dict. Unexpected behavior.
Warning: FieldReference values may be changed. If initial_dictionary contains a FieldReference with a value of type dict or FrozenConfigDict, that value is converted to ConfigDict.
- Parameters:
initial_dictionary (
Optional
[Mapping
[str
,Any
]]) –May be one of the following:
1) dict. In this case, all values of initial_dictionary that are dictionaries are also be converted to ConfigDict. However, dictionaries within values of non-dict type are untouched.
2) ConfigDict. In this case, all attributes are uncopied, and only the top-level object (self) is re-addressed. This is the same behavior as Python dict, list, and tuple.
3) FrozenConfigDict. In this case, initial_dictionary is converted to a ConfigDict version of the initial dictionary for the FrozenConfigDict (reversing any mutability changes FrozenConfigDict made).
type_safe (
bool
) – If set to True, once an attribute value is assigned, its type cannot be overridden without .ignore_type() context manager (default: True).convert_dict (
bool
) – If set to True, all dict used as value in the ConfigDict will automatically be converted to ConfigDict (default: True).
- class ParamGroupCfg[source]¶
Parameter group config.
- custom_keys¶
List of custom keys.
- Type:
list[str]
- lr_mult¶
Learning rate multiplier.
- Type:
NotRequired[float]
- decay_mult¶
Weight Decay multiplier.
- Type:
NotRequired[float]
- class ParameterSweepConfig(initial_dictionary=None, type_safe=True, convert_dict=True)[source]¶
Configuration for a parameter sweep.
Confguration object for a parameter sweep. It contains the minimal required configuration to run a parameter sweep.
- method¶
Sweep method that should be used (e.g. grid)
- Type:
str
- sampling_args¶
Arguments that should be passed to the sweep method. E.g. for grid, this would be a list of tuples of the form (parameter_name, parameter_values).
- Type:
list[tuple[str, Any]]
- suffix¶
Suffix that should be appended to the output directory. This will be interpreted as a string template and can contain references to the sampling_args. E.g. “lr_{lr:.2e}_bs_{batch_size}”.
- Type:
str
Creates an instance of FieldConfigDict.
- Parameters:
initial_dictionary (
Optional
[Mapping
[str
,Any
]]) –May be one of the following:
1) dict. In this case, all values of initial_dictionary that are dictionaries are also be converted to ConfigDict. However, dictionaries within values of non-dict type are untouched.
2) ConfigDict. In this case, all attributes are uncopied, and only the top-level object (self) is re-addressed. This is the same behavior as Python dict, list, and tuple.
3) FrozenConfigDict. In this case, initial_dictionary is converted to a ConfigDict version of the initial dictionary for the FrozenConfigDict (reversing any mutability changes FrozenConfigDict made).
type_safe (
bool
) – If set to True, once an attribute value is assigned, its type cannot be overridden without .ignore_type() context manager.convert_dict (
bool
) – If set to True, all dict used as value in the ConfigDict will automatically be converted to ConfigDict.