Logger
mlpoppyns.learning.logger.logger
Logger.
Utility functions for setting up and dealing with the logging subsystem in order to generate messages both to the console and to log useful info of the process to output files.
Authors:
Alberto Garcia Garcia (garciagarcia@ice.csic.es)
Copyright (c) MAGNESIA (ICE-CSIC)
setup_logging(log_dir, log_config_file='mlpoppyns/learning/logger/default_logger_config.json', default_level=logging.INFO)
Setup logging configuration.
Sets up the logging subsystem by reading its configuration from a JSON configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_dir
|
str
|
The directory to output the log files to. |
required |
log_config_file
|
str
|
Path to the JSON configuration file. |
'mlpoppyns/learning/logger/default_logger_config.json'
|
default_level
|
int
|
Default logging level. |
INFO
|
Source code in mlpoppyns/learning/logger/logger.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
mlpoppyns.learning.logger.tensorboard_writer
Tensorboard writer.
This module provides a class for integrating Tensorboard logging functionality into your project, allowing for the visualization of metrics.
Authors:
Alberto Garcia Garcia (garciagarcia@ice.csic.es)
TensorboardWriter
A class for writing logs to Tensorboard, supporting both torch.utils.tensorboard and tensorboardX.
Attributes:
| Name | Type | Description |
|---|---|---|
writer |
The Tensorboard writer object. |
|
selected_module |
The name of the selected module for writing logs. |
|
step |
The current step for logging. |
|
mode |
The current mode (e.g., "train" or "valid"). |
|
tb_writer_ftns |
A set of Tensorboard writing functions. |
|
tag_mode_exceptions |
A set of functions that do not require mode tags. |
|
timer |
A datetime object to track the time between steps. |
Source code in mlpoppyns/learning/logger/tensorboard_writer.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
__getattr__(name)
Provides dynamic access to Tensorboard logging methods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the Tensorboard method to access. |
required |
Returns:
| Type | Description |
|---|---|
Union[Callable, Any]
|
A wrapped function that adds additional information (step, tag) to the Tensorboard log entry. If visualization is configured to use returns add_data() methods of tensorboard with additional information (step, tag) added. Otherwise returns a blank function handle that does nothing. |
Source code in mlpoppyns/learning/logger/tensorboard_writer.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
__init__(log_dir, logger, enabled)
Initializes the TensorboardWriter with the specified log directory, logger, and enable flag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_dir
|
str
|
The directory where Tensorboard logs will be saved. |
required |
logger
|
Logger
|
The logger for displaying warnings or errors. |
required |
enabled
|
bool
|
Flag to enable or disable Tensorboard logging. |
required |
Source code in mlpoppyns/learning/logger/tensorboard_writer.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
set_step(step, mode='train')
Sets the current step and mode, and logs the steps per second.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int
|
The current step for logging. |
required |
mode
|
str
|
The current mode (default is "train"). |
'train'
|
Source code in mlpoppyns/learning/logger/tensorboard_writer.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |