Shortcuts

torchtraining.callbacks.tensorboard module

Special type of callbacks focused on tensorboard integration.

Note

IMPORTANT: Users need tensorboard package installed for this module to exist. You can install it via pip install torchtraining[tensorboard] (additional libraries for Image, Images, Video, Figure) will also be installed) or install tensorboard directly via pip install -U tensorboard or a-like command (in this case not all functions may be available, see PyTorch’s torch.utils.tensorboard.SummaryWriter docs for exact packages needed for each functionality).

Example:

# Assume iteration was defined and loss is 0th element of step
iteration = (
    tt.iterations.Iteration(...)
    ** tt.Select(loss=0)
    ** tt.device.CPU()
    ** tt.accumulators.Mean()
    ** tt.callbacks.tensorboard.Scalar(writer, "Network/Loss")
)
class torchtraining.callbacks.tensorboard.Audio(writer, name: str, flush: int = None, log: Union[str, int] = 'NONE', *args, **kwargs)[source]

Bases: torchtraining.callbacks.tensorboard._Tensorboard

Log audio to Tensorboard’s summary.

User should specify single writer instance to all torchtraining.callbacks.tensorboard objects used for training.

See torch.utils.tensorboard.writer.add_audio for more details.

Can be used similarly to torchtraining.callbacks.Logger

Parameters
  • writer (torch.utils.tensorboard.SummaryWriter) – Writer responsible for logging values.

  • name (str) – Name (tag) under which values will be logged into Tensorboard. Can be “/” separated to group values together, e.g. “Classifier/Loss” and “Classifier/Accuracy”

  • flush (int) – Flushes the event file to disk after flush steps. Call this method to make sure that all pending events have been written to disk.

  • log (str | int, optional) –

    Severity level for logging object’s actions. Available levels of logging:

    • NONE 0

    • TRACE 5

    • DEBUG 10

    • INFO 20

    • SUCCESS 25

    • WARNING 30

    • ERROR 40

    • CRITICAL 50

    Default: NONE (no logging, 0 priority)

  • *args – Variable length arguments passed to add_audio call.

  • **kwargs – Keyword variable length arguments passed to add_audio call.

class torchtraining.callbacks.tensorboard.Figure(writer, name: str, flush: int = None, log: Union[str, int] = 'NONE', *args, **kwargs)[source]

Bases: torchtraining.callbacks.tensorboard._Tensorboard

Log figure to Tensorboard’s summary.

User should specify single writer instance to all torchtraining.callbacks.tensorboard objects used for training.

See torch.utils.tensorboard.writer.add_figure for more details.

Can be used similarly to torchtraining.callbacks.Logger

Note that this requires the matplotlib package.

Parameters
  • writer (torch.utils.tensorboard.SummaryWriter) – Writer responsible for logging values.

  • name (str) – Name (tag) under which values will be logged into Tensorboard. Can be “/” separated to group values together, e.g. “Classifier/Loss” and “Classifier/Accuracy”

  • flush (int) – Flushes the event file to disk after flush steps. Call this method to make sure that all pending events have been written to disk.

  • log (str | int, optional) –

    Severity level for logging object’s actions. Available levels of logging:

    • NONE 0

    • TRACE 5

    • DEBUG 10

    • INFO 20

    • SUCCESS 25

    • WARNING 30

    • ERROR 40

    • CRITICAL 50

    Default: NONE (no logging, 0 priority)

  • *args – Variable length arguments passed to add_figure call.

  • **kwargs – Keyword variable length arguments passed to add_figure call.

class torchtraining.callbacks.tensorboard.Histogram(writer, name: str, flush: int = None, log: Union[str, int] = 'NONE', *args, **kwargs)[source]

Bases: torchtraining.callbacks.tensorboard._Tensorboard

Log histogram to Tensorboard’s summary.

User should specify single writer instance to all torchtraining.callbacks.tensorboard objects used for training.

See torch.utils.tensorboard.writer.add_histogram for more details.

Can be used similarly to torchtraining.callbacks.Logger

Parameters
  • writer (torch.utils.tensorboard.SummaryWriter) – Writer responsible for logging values.

  • name (str) – Name (tag) under which values will be logged into Tensorboard. Can be “/” separated to group values together, e.g. “Classifier/Loss” and “Classifier/Accuracy”

  • flush (int) – Flushes the event file to disk after flush steps. Call this method to make sure that all pending events have been written to disk.

  • log (str | int, optional) –

    Severity level for logging object’s actions. Available levels of logging:

    • NONE 0

    • TRACE 5

    • DEBUG 10

    • INFO 20

    • SUCCESS 25

    • WARNING 30

    • ERROR 40

    • CRITICAL 50

    Default: NONE (no logging, 0 priority)

  • *args – Variable length arguments passed to add_histogram call.

  • **kwargs – Keyword variable length arguments passed to add_histogram call.

class torchtraining.callbacks.tensorboard.Image(writer, name: str, flush: int = None, log: Union[str, int] = 'NONE', *args, **kwargs)[source]

Bases: torchtraining.callbacks.tensorboard._Tensorboard

Log image to Tensorboard’s summary.

User should specify single writer instance to all torchtraining.callbacks.tensorboard objects used for training.

See torch.utils.tensorboard.writer.add_image for more details.

Can be used similarly to torchtraining.callbacks.Logger

Parameters
  • writer (torch.utils.tensorboard.SummaryWriter) – Writer responsible for logging values.

  • name (str) – Name (tag) under which values will be logged into Tensorboard. Can be “/” separated to group values together, e.g. “Classifier/Loss” and “Classifier/Accuracy”

  • flush (int) – Flushes the event file to disk after flush steps. Call this method to make sure that all pending events have been written to disk.

  • log (str | int, optional) –

    Severity level for logging object’s actions. Available levels of logging:

    • NONE 0

    • TRACE 5

    • DEBUG 10

    • INFO 20

    • SUCCESS 25

    • WARNING 30

    • ERROR 40

    • CRITICAL 50

    Default: NONE (no logging, 0 priority)

  • *args – Variable length arguments passed to add_image call.

  • **kwargs – Keyword variable length arguments passed to add_image call.

class torchtraining.callbacks.tensorboard.Images(writer, name: str, flush: int = None, log: Union[str, int] = 'NONE', *args, **kwargs)[source]

Bases: torchtraining.callbacks.tensorboard._Tensorboard

Log images to Tensorboard’s summary.

User should specify single writer instance to all torchtraining.callbacks.tensorboard objects used for training.

See torch.utils.tensorboard.writer.add_images for more details.

Can be used similarly to torchtraining.callbacks.Logger

Parameters
  • writer (torch.utils.tensorboard.SummaryWriter) – Writer responsible for logging values.

  • name (str) – Name (tag) under which values will be logged into Tensorboard. Can be “/” separated to group values together, e.g. “Classifier/Loss” and “Classifier/Accuracy”

  • flush (int) – Flushes the event file to disk after flush steps. Call this method to make sure that all pending events have been written to disk.

  • log (str | int, optional) –

    Severity level for logging object’s actions. Available levels of logging:

    • NONE 0

    • TRACE 5

    • DEBUG 10

    • INFO 20

    • SUCCESS 25

    • WARNING 30

    • ERROR 40

    • CRITICAL 50

    Default: NONE (no logging, 0 priority)

  • *args – Variable length arguments passed to add_images call.

  • **kwargs – Keyword variable length arguments passed to add_images call.

class torchtraining.callbacks.tensorboard.Mesh(writer, name: str, flush: int = None, log: Union[str, int] = 'NONE', *args, **kwargs)[source]

Bases: torchtraining.callbacks.tensorboard._Tensorboard

Log mesh to Tensorboard’s summary.

User should specify single writer instance to all torchtraining.callbacks.tensorboard objects used for training.

See torch.utils.tensorboard.writer.add_mesh for more details.

Can be used similarly to torchtraining.callbacks.Logger

Parameters
  • writer (torch.utils.tensorboard.SummaryWriter) – Writer responsible for logging values.

  • name (str) – Name (tag) under which values will be logged into Tensorboard. Can be “/” separated to group values together, e.g. “Classifier/Loss” and “Classifier/Accuracy”

  • flush (int) – Flushes the event file to disk after flush steps. Call this method to make sure that all pending events have been written to disk.

  • log (str | int, optional) –

    Severity level for logging object’s actions. Available levels of logging:

    • NONE 0

    • TRACE 5

    • DEBUG 10

    • INFO 20

    • SUCCESS 25

    • WARNING 30

    • ERROR 40

    • CRITICAL 50

    Default: NONE (no logging, 0 priority)

  • *args – Variable length arguments passed to add_mesh call.

  • **kwargs – Keyword variable length arguments passed to add_mesh call.

class torchtraining.callbacks.tensorboard.PRCurve(writer, name: str, flush: int = None, log: Union[str, int] = 'NONE', *args, **kwargs)[source]

Bases: torchtraining.callbacks.tensorboard._Tensorboard

Log prcurve to Tensorboard’s summary.

User should specify single writer instance to all torchtraining.callbacks.tensorboard objects used for training.

See torch.utils.tensorboard.writer.add_prcurve for more details.

Can be used similarly to torchtraining.callbacks.Logger

Parameters
  • writer (torch.utils.tensorboard.SummaryWriter) – Writer responsible for logging values.

  • name (str) – Name (tag) under which values will be logged into Tensorboard. Can be “/” separated to group values together, e.g. “Classifier/Loss” and “Classifier/Accuracy”

  • flush (int) – Flushes the event file to disk after flush steps. Call this method to make sure that all pending events have been written to disk.

  • log (str | int, optional) –

    Severity level for logging object’s actions. Available levels of logging:

    • NONE 0

    • TRACE 5

    • DEBUG 10

    • INFO 20

    • SUCCESS 25

    • WARNING 30

    • ERROR 40

    • CRITICAL 50

    Default: NONE (no logging, 0 priority)

  • *args – Variable length arguments passed to add_prcurve call.

  • **kwargs – Keyword variable length arguments passed to add_prcurve call.

forward(data)[source]
Parameters

data – Tensor (or a-like) to be logged into Tensorboard

class torchtraining.callbacks.tensorboard.Scalar(writer, name: str, flush: int = None, log: Union[str, int] = 'NONE', *args, **kwargs)[source]

Bases: torchtraining.callbacks.tensorboard._Tensorboard

Log scalar to Tensorboard’s summary.

User should specify single writer instance to all torchtraining.callbacks.tensorboard objects used for training.

See torch.utils.tensorboard.writer.add_scalar for more details.

Can be used similarly to torchtraining.callbacks.Logger

Parameters
  • writer (torch.utils.tensorboard.SummaryWriter) – Writer responsible for logging values.

  • name (str) – Name (tag) under which values will be logged into Tensorboard. Can be “/” separated to group values together, e.g. “Classifier/Loss” and “Classifier/Accuracy”

  • flush (int) – Flushes the event file to disk after flush steps. Call this method to make sure that all pending events have been written to disk.

  • log (str | int, optional) –

    Severity level for logging object’s actions. Available levels of logging:

    • NONE 0

    • TRACE 5

    • DEBUG 10

    • INFO 20

    • SUCCESS 25

    • WARNING 30

    • ERROR 40

    • CRITICAL 50

    Default: NONE (no logging, 0 priority)

  • *args – Variable length arguments passed to add_scalar call.

  • **kwargs – Keyword variable length arguments passed to add_scalar call.

class torchtraining.callbacks.tensorboard.Scalars(writer, name: str, flush: int = None, log: Union[str, int] = 'NONE', *args, **kwargs)[source]

Bases: torchtraining.callbacks.tensorboard._Tensorboard

Log scalars to Tensorboard’s summary.

User should specify single writer instance to all torchtraining.callbacks.tensorboard objects used for training.

See torch.utils.tensorboard.writer.add_scalars for more details.

Can be used similarly to torchtraining.callbacks.Logger

Parameters
  • writer (torch.utils.tensorboard.SummaryWriter) – Writer responsible for logging values.

  • name (str) – Name (tag) under which values will be logged into Tensorboard. Can be “/” separated to group values together, e.g. “Classifier/Loss” and “Classifier/Accuracy”

  • flush (int) – Flushes the event file to disk after flush steps. Call this method to make sure that all pending events have been written to disk.

  • log (str | int, optional) –

    Severity level for logging object’s actions. Available levels of logging:

    • NONE 0

    • TRACE 5

    • DEBUG 10

    • INFO 20

    • SUCCESS 25

    • WARNING 30

    • ERROR 40

    • CRITICAL 50

    Default: NONE (no logging, 0 priority)

  • *args – Variable length arguments passed to add_scalars call.

  • **kwargs – Keyword variable length arguments passed to add_scalars call.

class torchtraining.callbacks.tensorboard.Text(writer, name: str, flush: int = None, log: Union[str, int] = 'NONE', *args, **kwargs)[source]

Bases: torchtraining.callbacks.tensorboard._Tensorboard

Log text to Tensorboard’s summary.

User should specify single writer instance to all torchtraining.callbacks.tensorboard objects used for training.

See torch.utils.tensorboard.writer.add_text for more details.

Can be used similarly to torchtraining.callbacks.Logger

Parameters
  • writer (torch.utils.tensorboard.SummaryWriter) – Writer responsible for logging values.

  • name (str) – Name (tag) under which values will be logged into Tensorboard. Can be “/” separated to group values together, e.g. “Classifier/Loss” and “Classifier/Accuracy”

  • flush (int) – Flushes the event file to disk after flush steps. Call this method to make sure that all pending events have been written to disk.

  • log (str | int, optional) –

    Severity level for logging object’s actions. Available levels of logging:

    • NONE 0

    • TRACE 5

    • DEBUG 10

    • INFO 20

    • SUCCESS 25

    • WARNING 30

    • ERROR 40

    • CRITICAL 50

    Default: NONE (no logging, 0 priority)

  • *args – Variable length arguments passed to add_text call.

  • **kwargs – Keyword variable length arguments passed to add_text call.

class torchtraining.callbacks.tensorboard.Video(writer, name: str, flush: int = None, log: Union[str, int] = 'NONE', *args, **kwargs)[source]

Bases: torchtraining.callbacks.tensorboard._Tensorboard

Log video to Tensorboard’s summary.

User should specify single writer instance to all torchtraining.callbacks.tensorboard objects used for training.

See torch.utils.tensorboard.writer.add_video for more details.

Can be used similarly to torchtraining.callbacks.Logger

Note that this requires the moviepy package.

Parameters
  • writer (torch.utils.tensorboard.SummaryWriter) – Writer responsible for logging values.

  • name (str) – Name (tag) under which values will be logged into Tensorboard. Can be “/” separated to group values together, e.g. “Classifier/Loss” and “Classifier/Accuracy”

  • flush (int) – Flushes the event file to disk after flush steps. Call this method to make sure that all pending events have been written to disk.

  • log (str | int, optional) –

    Severity level for logging object’s actions. Available levels of logging:

    • NONE 0

    • TRACE 5

    • DEBUG 10

    • INFO 20

    • SUCCESS 25

    • WARNING 30

    • ERROR 40

    • CRITICAL 50

    Default: NONE (no logging, 0 priority)

  • *args – Variable length arguments passed to add_video call.

  • **kwargs – Keyword variable length arguments passed to add_video call.