dgs.models.module.BaseModule¶
- class dgs.models.module.BaseModule(config: dict[str, any], path: list[str])[source]¶
Base class for all custom modules.
Description¶
Every Module is a building block that can be replaced with other building blocks. This defines a base module all of those building blocks inherit. This class should not be called directly and should only be inherited by other classes.
Every module has access to the global configuration for parameters like the modules’ device(s). Additionally, every module will have own parameters (params) which are a sub node of the overall configuration.
Configuration¶
- device: (Device)
The torch device to run this module and tracker on.
- is_training: (bool)
Whether the general torch modules should train or evaluate. Modes of different modules can be set individually using ‘.eval()’, ‘.train()’, or the functions from
dgs.utils.torchtools
.- name (str):
The name of this configuration. Mostly used for printing, logging, and file saving.
Optional Configuration¶
- print_prio: (str, optional)
How much information should be printed while running. “INFO” will print status reports but no debugging information. Default:
DEF_VAL.base.print_prio
.- description (str, optional):
The description of the overall configuration. Default:
DEF_VAL.base.description
.- log_dir (FilePath, optional):
Path to directory where all the files of this run are saved. The date will be added to the path if
log_dir_add_date
isTrue
. Default:DEF_VAL.base.log_dir
.- log_dir_add_date (bool, optional):
Whether to append the date to the
log_dir
. IfTrue
, The subdirectory that represents today will be added to the log directory (“./YYYYMMDD/”). Default:DEF_VAL.base.log_dir_add_date
.- log_dir_suffix (str, optional):
Suffix to add to the log directory. Default:
DEF_VAL.base.log_dir_suffix
.- precision (Union[type, str, torch.dtype], optional)
The precision at which this module should operate. Default:
DEF_VAL.base.precision
.
- config¶
The overall configuration of the whole algorithm.
- params¶
The parameters for this specific module.
- _path¶
Location of params within config as a node path.
- param config:
The overall configuration of the whole algorithm
- param path:
Keys of config to the parameters of the current module e.g. the parameters for the pose estimator will be located in a pose-estimator subgroup of the config those key-based paths may be even deeper, just make sure that only information about this specific model is stored in params.
- __init__(config: dict[str, any], path: list[str])[source]¶
Methods
configure_torch_module
(module[, train])Set compute mode and send model to the device or multiple parallel devices if applicable.
Terminate this module and all of its submodules.
validate_params
(validations[, attrib_name])Given per key validations, validate this module's parameters.
Attributes
Get the device of this module.
Get whether this module is set to training-mode.
Get the name of the module.
Get the escaped name of the module usable in filepaths by replacing spaces and underscores.
Get the (floating point) precision used in multiple parts of this module.