virtex.utils.timer


class virtex.utils.timer.Timer(start_from: int = 1, total_iterations: Optional[int] = None, window_size: int = 20)[source]

Bases: object

A simple timer to record time per iteration and ETA of training. ETA is estimated by moving window average with fixed window size.

Parameters
  • start_from – Iteration from which counting should be started/resumed.

  • total_iterations – Total number of iterations. ETA will not be tracked (will remain “N/A”) if this is not provided.

  • window_size – Window size to calculate ETA based on past few iterations.

tic() None[source]

Start recording time: call at the beginning of iteration.

toc() None[source]

Stop recording time: call at the end of iteration.

property stats: str

Return a single string with current iteration, time and ETA.

property eta_hhmm: str

Return ETA in the form of hh mm string.