norse.torch.utils.tensorboard module

Tensorboard related utilities.

norse.torch.utils.tensorboard.hook_spike_activity_mean(key, writer)[source]

Generates a hook that can be applied to stateful torch Modules. The hook plots the mean neuron activity as a line, assuming that the module output is a tuple of (spikes, state). That is, this will not work on modules that only returns a single tensor as output (i. e. have no state).

Read more about hooks in PyTorch Modules in the Module documentation.

Example

>>> from torch.utils.tensorboard import SummaryWriter
>>> import norse.torch as snn
>>> from snn.util import tensorboard
>>> hook = tensorboard.hook_spike_activity_mean("lif", SummaryWriter())
>>> snn.LIFCell().register_forward_hook(hook)
Parameters
  • key (str) – The name of the module as referred to in Tensorboard

  • writer (SummaryWriter) – The Tensorboard Writer to log to.

Return type

Callable[[Module, Tuple[Tensor, Any], Any], None]

Returns

A hook that will plot the mean neuron spike activity when registered to a Torch module.

norse.torch.utils.tensorboard.hook_spike_activity_sum(key, writer)[source]

Generates a hook that can be applied to stateful torch Modules. The hook plots the summed neuron activity as a line, assuming that the module output is a tuple of (spikes, state). That is, this will not work on modules that only returns a single tensor as output (i. e. have no state).

Read more about hooks in PyTorch Modules in the Module documentation.

Example

>>> from torch.utils.tensorboard import SummaryWriter
>>> import norse.torch as snn
>>> from snn.util import tensorboard
>>> hook = tensorboard.hook_spike_activity_sum("lif", SummaryWriter())
>>> snn.LIFCell().register_forward_hook(hook)
Parameters
  • key (str) – The name of the module as referred to in Tensorboard

  • writer (SummaryWriter) – The Tensorboard Writer to log to.

Return type

Callable[[Module, Tuple[Tensor, Any], Any], None]

Returns

A hook that will plot the mean neuron spike activity when registered to a Torch module.

norse.torch.utils.tensorboard.hook_spike_histogram_mean(key, writer)[source]

Generates a hook that can be applied to stateful torch Modules. The hook shows a histogram of mean neuron activity, assuming that the module output is a tuple of (spikes, state). That is, this will not work on modules that only returns a single tensor as output (i. e. have no state).

Read more about hooks in PyTorch Modules in the Module documentation.

Example

>>> from torch.utils.tensorboard import SummaryWriter
>>> import norse.torch as snn
>>> from snn.util import tensorboard
>>> hook = tensorboard.hook_spike_histogram_mean("lif", SummaryWriter())
>>> snn.LIFCell().register_forward_hook(hook)
Parameters
  • key (str) – The name of the module as referred to in Tensorboard

  • writer (SummaryWriter) – The Tensorboard Writer to log to.

Return type

Callable[[Module, Tuple[Tensor, Any], Any], None]

Returns

A hook that will plot the mean neuron spike activity when registered to a Torch module.

norse.torch.utils.tensorboard.hook_spike_histogram_sum(key, writer)[source]

Generates a hook that can be applied to stateful torch Modules. The hook shows a histogram of the summed neuron activity, assuming that the module output is a tuple of (spikes, state). That is, this will not work on modules that only returns a single tensor as output (i. e. have no state).

Read more about hooks in PyTorch Modules in the Module documentation.

Example

>>> from torch.utils.tensorboard import SummaryWriter
>>> import norse.torch as snn
>>> from snn.util import tensorboard
>>> hook = tensorboard.hook_spike_histogram_sum("lif", SummaryWriter())
>>> snn.LIFCell().register_forward_hook(hook)
Parameters
  • key (str) – The name of the module as referred to in Tensorboard

  • writer (SummaryWriter) – The Tensorboard Writer to log to.

Return type

Callable[[Module, Tuple[Tensor, Any], Any], None]

Returns

A hook that will plot the mean neuron spike activity when registered to a Torch module.

norse.torch.utils.tensorboard.hook_spike_image(key, writer)[source]

Generates a hook that can be applied to stateful torch Modules. The hook plots the spiked output, assuming that the module output is a tuple of (spikes, state). That is, this will not work on modules that only returns a single tensor as output (i. e. have no state).

Read more about hooks in PyTorch Modules in the Module documentation.

Example

>>> from torch.utils.tensorboard import SummaryWriter
>>> import norse.torch as snn
>>> from snn.util import tensorboard
>>> hook = tensorboard.hook_spike_image("lif", SummaryWriter())
>>> snn.LIFCell().register_forward_hook(hook)
Parameters
  • key (str) – The name of the module as referred to in Tensorboard

  • writer (SummaryWriter) – The Tensorboard Writer to log to.

Return type

Callable[[Module, Tuple[Tensor, Any], Any], None]

Returns

A hook that will plot the spike activity as an image when registered to a Torch module.