flambe.logging.utils

Module Contents

flambe.logging.utils.ValueT[source]
flambe.logging.utils.d :Dict[str, Callable][source]
flambe.logging.utils.coloredlogs[source]
flambe.logging.utils._get_context_logger() → logging.Logger[source]

Return the appropriate logger related to the module that logs.

flambe.logging.utils.get_trial_dir() → str[source]

Get the output path used by the currently active trial.

Returns:The output path
Return type:str
flambe.logging.utils.log(tag: str, data: ValueT, global_step: int, walltime: Optional[float] = None) → None[source]

Log data to tensorboard and console (convenience function)

Inspects type of data and uses the appropriate wrapper for tensorboard to consume the data. Supports floats (scalar), dictionary mapping tags to gloats (scalars), and strings (text).

Parameters:
  • tag (str) – Name of data, used as the tensorboard tag
  • data (ValueT) – The scalar or text to log
  • global_step (int) – Iteration number associated with data
  • walltime (Optional[float]) – Walltime for data (the default is None).

Examples

Normally you would have to do the following to log a scalar >>> import logging; from flambe.logging import ScalarT >>> logger = logging.getLogger(__name__) >>> logger.info(ScalarT(tag, data, step, walltime)) But this method allows you to write a more concise statement with a common interface >>> from flambe.logging import log >>> log(tag, data, step)

flambe.logging.utils.log_scalar(tag: str, data: float, global_step: int, walltime: Optional[float] = None, logger: Optional[logging.Logger] = None) → None[source]

Log tensorboard compatible scalar value with common interface

Parameters:
  • tag (str) – Tensorboard tag associated with scalar data
  • data (float) – Scalar float value
  • global_step (int) – The global step or iteration number
  • walltime (Optional[float]) – Current walltime, for example from time.time()
  • logger (Optional[logging.Logger]) – logger to use for logging the scalar
flambe.logging.utils.log_scalars(tag: str, data: Dict[str, float], global_step: int, walltime: Optional[float] = None, logger: Optional[logging.Logger] = None) → None[source]

Log tensorboard compatible scalar values with common interface

Parameters:
  • tag (str) – Main tensorboard tag associated with all data
  • data (Dict[str, float]) – Scalar float value
  • global_step (int) – The global step or iteration number
  • walltime (Optional[float]) – Current walltime, for example from time.time()
  • logger (Optional[logging.Logger]) – logger to use for logging the scalar
flambe.logging.utils.log_text(tag: str, data: str, global_step: int, walltime: Optional[float] = None, logger: Optional[logging.Logger] = None) → None[source]

Log tensorboard compatible text value with common interface

Parameters:
  • tag (str) – Tensorboard tag associated with data
  • data (str) – Scalar float value
  • global_step (int) – The global step or iteration number
  • walltime (Optional[float]) – Current walltime, for example from time.time()
  • logger (Optional[logging.Logger]) – logger to use for logging the scalar
flambe.logging.utils.log_image(tag: str, data: str, global_step: int, walltime: Optional[float] = None, logger: Optional[logging.Logger] = None) → None[source]

Log tensorboard compatible image value with common interface

Parameters:
  • tag (str) – Tensorboard tag associated with data
  • data (str) – Scalar float value
  • global_step (int) – The global step or iteration number
  • walltime (Optional[float]) – Current walltime, for example from time.time()
  • logger (Optional[logging.Logger]) – logger to use for logging the scalar
flambe.logging.utils.log_pr_curve(tag: str, labels: Union[torch.Tensor, numpy.array], predictions: Union[torch.Tensor, numpy.array], global_step: int, num_thresholds: int = 127, walltime: Optional[float] = None, logger: Optional[logging.Logger] = None) → None[source]

Log tensorboard compatible image value with common interface

Parameters:
  • tag (str) – Data identifier
  • labels (Union[torch.Tensor, numpy.array]) – Containing 0, 1 values
  • predictions (Union[torch.Tensor, numpy.array]) – Containing 0<=x<=1 values. Needs to match labels size
  • num_thresholds (int = 127) – The number of thresholds to evaluate. Max value allowed 127.
  • weights (Optional[float] = None) – No description provided.
  • global_step (int) – Iteration associated with this value
  • walltime (float) – Wall clock time associated with this value
  • logger (Optional[logging.Logger]) – logger to use for logging the scalar
flambe.logging.utils.log_histogram(tag: str, data: str, global_step: int, bins: str = 'auto', walltime: Optional[float] = None, logger: Optional[logging.Logger] = None) → None[source]

Log tensorboard compatible image value with common interface

Parameters:
  • tag (str) – Tensorboard tag associated with data
  • data (str) – Scalar float value
  • global_step (int) – The global step or iteration number
  • walltime (Optional[float]) – Current walltime, for example from time.time()
  • logger (Optional[logging.Logger]) – logger to use for logging the scalar