utils package
Submodules
utils.utils module
- check_config(config: DictConfig) None [source]
- A couple of optional utilities, controlled by main config file.
check for required configs in the main config
disabling warnings
easier access to debug mode
forcing debug friendly configuration
forcing multi-gpu friendly configuration
setting seed for random number generators
setting up default csv logger
- Parameters:
config (DictConfig) – the main hydra config
- empty(*args, **kwargs)[source]
This function does nothing. It is used to disable logging of hyperparameters by Lightning loggers.
- Parameters:
args –
kwargs –
- finish(config: DictConfig, task: LightningModule, model: LightningModule, datamodule: LightningDataModule, trainer: Trainer, callbacks: List[Callback], logger: List[LightningLoggerBase]) None [source]
Makes sure everything closed properly.
- Parameters:
config (DictConfig) – Hydra config
task (pl.LightningModule) – Lightning task
model (pl.LightningModule) – Lightning model
datamodule (pl.LightningDataModule) – Lightning datamodule
trainer (pl.Trainer) – Lightning trainer
callbacks (List[pl.Callback]) – Lightning callbacks
logger (List[pl.loggers.LightningLoggerBase]) – Lightning logger
- get_logger(name='utils.utils', level=20) Logger [source]
Gets the Python logger of the system.
- Parameters:
name (str) – name of the logger you want to get defaults to __name__
level – logging level defaults to logging.INFO
- Returns:
Python logger
- Return type:
logging.Logger
- log_hyperparameters(config: DictConfig, model: LightningModule, trainer: Trainer) None [source]
This method controls which parameters from Hydra config are saved by Lightning loggers.
- Additionally, saves:
sizes of train, val, test dataset
number of trainable model parameters
- Parameters:
config (DictConfig) – Hydra config
model (pl.LightningModule) – Lightning model
trainer (pl.Trainer) – Lightning trainer
- print_config(config: DictConfig, fields: Sequence[str] = ('trainer', 'task', 'model', 'optimizer', 'datamodule', 'callbacks', 'loss', 'metric', 'logger', 'seed', 'train', 'test', 'predict'), resolve: bool = True, add_missing_fields: bool = True) None [source]
Prints content of DictConfig using Rich library and its tree structure.
- Parameters:
config (DictConfig) – Hydra config
fields (Sequence[str]) – Determines which main fields from config will be printed and in what order.
resolve (bool) – Whether to resolve reference fields of DictConfig.
add_missing_fields (bool) – Whether to add missing fields from config to fields.