torchpack.callbacks package

Submodules

torchpack.callbacks.callback module

torchpack.callbacks.checkpoint module

class torchpack.callbacks.checkpoint.Saver(*, max_to_keep: int = 4, save_dir: Optional[str] = None)[source]

Bases: torchpack.callbacks.callback.Callback

Save the checkpoint once triggered.

master_only = True
class torchpack.callbacks.checkpoint.MinSaver(scalar: str, *, name: Optional[str] = None, save_dir: Optional[str] = None)[source]

Bases: torchpack.callbacks.checkpoint.BestSaver

Save the checkpoint with minimum value of some scalar in trainer.summary.

extreme = 'min'
class torchpack.callbacks.checkpoint.MaxSaver(scalar: str, *, name: Optional[str] = None, save_dir: Optional[str] = None)[source]

Bases: torchpack.callbacks.checkpoint.BestSaver

Save the checkpoint with maximum value of some scalar in trainer.summary.

extreme = 'max'
class torchpack.callbacks.checkpoint.SaverRestore(load_dir: Optional[str] = None)[source]

Bases: torchpack.callbacks.callback.Callback

torchpack.callbacks.inference module

class torchpack.callbacks.inference.InferenceRunner(dataflow: torch.utils.data.dataloader.DataLoader, *, callbacks: List[torchpack.callbacks.callback.Callback])[source]

Bases: torchpack.callbacks.callback.Callback

A callback that runs inference with a list of Callback.

torchpack.callbacks.metainfo module

class torchpack.callbacks.metainfo.MetaInfoSaver(save_dir: Optional[str] = None)[source]

Bases: torchpack.callbacks.callback.Callback

master_only = True

torchpack.callbacks.metrics module

class torchpack.callbacks.metrics.TopKCategoricalAccuracy(k: int, *, output_tensor: str = 'outputs', target_tensor: str = 'targets', name: str = 'accuracy')[source]

Bases: torchpack.callbacks.callback.Callback

class torchpack.callbacks.metrics.CategoricalAccuracy(*, output_tensor: str = 'outputs', target_tensor: str = 'targets', name: str = 'accuracy')[source]

Bases: torchpack.callbacks.metrics.TopKCategoricalAccuracy

class torchpack.callbacks.metrics.MeanSquaredError(*, output_tensor: str = 'outputs', target_tensor: str = 'targets', name: str = 'error')[source]

Bases: torchpack.callbacks.callback.Callback

class torchpack.callbacks.metrics.MeanAbsoluteError(*, output_tensor: str = 'outputs', target_tensor: str = 'targets', name: str = 'error')[source]

Bases: torchpack.callbacks.callback.Callback

torchpack.callbacks.progress module

class torchpack.callbacks.progress.ProgressBar(scalars: Union[str, List[str]] = '*')[source]

Bases: torchpack.callbacks.callback.Callback

A progress bar based on tqdm.

master_only = True
class torchpack.callbacks.progress.EstimatedTimeLeft(*, last_k_epochs: int = 8)[source]

Bases: torchpack.callbacks.callback.Callback

Estimate the time left until completion.

master_only = True

torchpack.callbacks.trackers module

class torchpack.callbacks.trackers.GPUUtilizationTracker(*, devices: Optional[List[int]] = None)[source]

Bases: torchpack.callbacks.callback.Callback

Track the average GPU utilization within an epoch. It will start a process to track GPU utilization through NVML every second within the epoch (the time of trigger_epoch is not included). This callback creates a process, therefore it is not safe to be used with MPI.

master_only = True
class torchpack.callbacks.trackers.ThroughputTracker(*, samples_per_step: Optional[int] = None)[source]

Bases: torchpack.callbacks.callback.Callback

Track the throughput within an epoch (the time of trigger_epoch is not included).

master_only = True

torchpack.callbacks.triggers module

class torchpack.callbacks.triggers.EnableCallbackIf(callback: torchpack.callbacks.callback.Callback, predicate: Callable[[torchpack.callbacks.callback.Callback], bool])[source]

Bases: torchpack.callbacks.callback.ProxyCallback

Enable the callback only if some condition holds.

class torchpack.callbacks.triggers.PeriodicTrigger(callback: torchpack.callbacks.callback.Callback, *, every_k_epochs: Optional[int] = None, every_k_steps: Optional[int] = None)[source]

Bases: torchpack.callbacks.callback.ProxyCallback

Trigger the callback every k steps or every k epochs.

class torchpack.callbacks.triggers.PeriodicCallback(callback: torchpack.callbacks.callback.Callback, *, every_k_epochs: Optional[int] = None, every_k_steps: Optional[int] = None)[source]

Bases: torchpack.callbacks.triggers.EnableCallbackIf

Enable the callback every k steps or every k epochs. Note that this can only make a callback less frequent.

torchpack.callbacks.writers module

class torchpack.callbacks.writers.SummaryWriter[source]

Bases: torchpack.callbacks.callback.Callback

Base class for all summary writers.

add_image(name: str, tensor: numpy.ndarray) → None[source]
add_scalar(name: str, scalar: Union[int, float]) → None[source]
master_only = True
class torchpack.callbacks.writers.ConsoleWriter(scalars: Union[str, List[str]] = '*')[source]

Bases: torchpack.callbacks.writers.SummaryWriter

Write scalar summaries to console (and logger).

class torchpack.callbacks.writers.TFEventWriter(*, save_dir: Optional[str] = None)[source]

Bases: torchpack.callbacks.writers.SummaryWriter

Write summaries to TensorFlow event file.

class torchpack.callbacks.writers.JSONLWriter(save_dir: Optional[str] = None)[source]

Bases: torchpack.callbacks.writers.SummaryWriter

Write scalar summaries to JSONL file.

Module contents