Shortcuts

logger

Functions

merge_dicts

Merge a sequence with dictionaries into one dictionary by aggregating the same keys with some given function.

Classes

DummyLogger

Dummy logger for internal use.

Logger

Base class for experiment loggers.

Abstract base class used to build new loggers.

class lightning.pytorch.loggers.logger.DummyLogger[소스]

기반 클래스: 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_hyperparams(*args, **kwargs)[소스]

Record hyperparameters.

매개변수
  • paramsNamespace or Dict containing the hyperparameters

  • args (Any) – Optional positional arguments, depends on the specific logger being used

  • kwargs (Any) – Optional keyword arguments, depends on the specific logger being used

반환 형식

None

log_metrics(*args, **kwargs)[소스]

Records metrics. This method logs metrics as soon as it received them.

매개변수
  • metrics – Dictionary with metric names as keys and measured quantities as values

  • step – Step number at which the metrics should be recorded

반환 형식

None

property experiment: lightning.fabric.loggers.logger._DummyExperiment

Return the experiment object associated with this logger.

반환 형식

_DummyExperiment

property name: str

Return the experiment name.

반환 형식

str

property version: str

Return the experiment version.

반환 형식

str

class lightning.pytorch.loggers.logger.Logger[소스]

기반 클래스: lightning.fabric.loggers.logger.Logger, abc.ABC

Base class for experiment loggers.

after_save_checkpoint(checkpoint_callback)[소스]

Called after model checkpoint callback saves a new checkpoint.

매개변수

checkpoint_callback (ModelCheckpoint) – the model checkpoint callback instance

반환 형식

None

property save_dir: Optional[str]

Return the root directory where experiment logs get saved, or None if the logger does not save data locally.

반환 형식

Optional[str]

lightning.pytorch.loggers.logger.merge_dicts(dicts, agg_key_funcs=None, default_func=<function mean>)[소스]

Merge a sequence with dictionaries into one dictionary by aggregating the same keys with some given function.

매개변수
  • 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.

반환 형식

Dict

반환

Dictionary with merged values.

예제

>>> 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}