logger¶
Functions
Merge a sequence with dictionaries into one dictionary by aggregating the same keys with some given function. |
Classes
Dummy logger for internal use. |
|
Base class for experiment loggers. |
Abstract base class used to build new loggers.
- class lightning.pytorch.loggers.logger.DummyLogger[source]¶
Bases:
lightning.pytorch.loggers.logger.Logger
Dummy logger for internal use.
It is useful if we want to disable user’s logger for a feature, but still ensure that user code can run
- log_metrics(*args, **kwargs)[source]¶
Records metrics. This method logs metrics as soon as it received them.
- property experiment: lightning.fabric.loggers.logger._DummyExperiment¶
Return the experiment object associated with this logger.
- Return type
_DummyExperiment
- class lightning.pytorch.loggers.logger.Logger[source]¶
Bases:
lightning.fabric.loggers.logger.Logger
,abc.ABC
Base class for experiment loggers.
- after_save_checkpoint(checkpoint_callback)[source]¶
Called after model checkpoint callback saves a new checkpoint.
- Parameters
checkpoint_callback¶ (
ModelCheckpoint
) – the model checkpoint callback instance- Return type
- lightning.pytorch.loggers.logger.merge_dicts(dicts, agg_key_funcs=None, default_func=<function mean>)[source]¶
Merge a sequence with dictionaries into one dictionary by aggregating the same keys with some given function.
- Parameters
dicts¶ (
Sequence
[Mapping
]) – Sequence of dictionaries to be merged.agg_key_funcs¶ (
Optional
[Mapping
]) – Mapping from key name to function. This function will aggregate a list of values, obtained from the same key of all dictionaries. If some key has no specified aggregation function, the default one will be used. Default is:None
(all keys will be aggregated by the default function).default_func¶ (
Callable
[[Sequence
[float
]],float
]) – Default function to aggregate keys, which are not presented in the agg_key_funcs map.
- Return type
- Returns
Dictionary with merged values.
Examples
>>> import pprint >>> d1 = {'a': 1.7, 'b': 2.0, 'c': 1, 'd': {'d1': 1, 'd3': 3}} >>> d2 = {'a': 1.1, 'b': 2.2, 'v': 1, 'd': {'d1': 2, 'd2': 3}} >>> d3 = {'a': 1.1, 'v': 2.3, 'd': {'d3': 3, 'd4': {'d5': 1}}} >>> dflt_func = min >>> agg_funcs = {'a': np.mean, 'v': max, 'd': {'d1': sum}} >>> pprint.pprint(merge_dicts([d1, d2, d3], agg_funcs, dflt_func)) {'a': 1.3, 'b': 2.0, 'c': 1, 'd': {'d1': 3, 'd2': 3, 'd3': 3, 'd4': {'d5': 1}}, 'v': 2.3}