torchdistill.misc


torchdistill.misc.log

torchdistill.misc.log.setup_log_file(log_file_path)[source]

Sets a file handler with log_file_path to write a log file.

Parameters:

log_file_path (str) – log file path.

class torchdistill.misc.log.SmoothedValue(window_size=20, fmt=None)[source]

A deque-based value object tracks a series of values and provides access to smoothed values over a window or the global series average. The original implementation is https://github.com/pytorch/vision/blob/main/references/classification/utils.py

Parameters:
  • window_size (int) – window size.

  • fmt (str or None) – text format.

update(value, n=1)[source]

Appends value.

Parameters:
  • value (float or int) – value to be added.

  • n (int) – sample count.

synchronize_between_processes()[source]

Synchronizes between processes.

Warning

It does not synchronize the deque.

class torchdistill.misc.log.MetricLogger(delimiter='\t')[source]

A metric logger with SmoothedValue. The original implementation is https://github.com/pytorch/vision/blob/main/references/classification/utils.py

Parameters:

delimiter (str) – delimiter in a log message.

update(**kwargs)[source]

Updates a metric dict whose values are SmoothedValue.

Parameters:

kwargs (dict) – keys and values.

synchronize_between_processes()[source]

Synchronizes between processes.

add_meter(name, meter)[source]

Add a new metric name and value.

Parameters:
  • name (str) – metric name.

  • meter (SmoothedValue) – smoothed value.

log_every(iterable, log_freq, header=None)[source]

Add a new metric name and value.

Parameters:
  • iterable (Iterable) – iterable object (e.g., data loader).

  • log_freq (int) – log frequency.

  • header (str) – log message header.

Returns:

item in iterative.

Return type:

Any