This module provides support for importing models into the sinabs from pytorch. It currently only has limited capability.

from_model(model, input_shape=None, threshold=1.0, threshold_low=- 1.0, membrane_subtract=None, bias_rescaling=1.0, batch_size=None, synops=True, add_spiking_output=False)

Converts a Torch model and returns a Sinabs network object. The modules in the model are analyzed, and a copy is returned, with all ReLUs, LeakyReLUs and NeuromorphicReLUs turned into SpikingLayers.

  • model – a Torch model

  • input_shape – If provided, the layer dimensions are computed. Otherwise they will be computed at the first forward pass.

  • threshold – The membrane potential threshold for spiking in convolutional and linear layers (same for all layers).

  • threshold_low – The lower bound of the potential in convolutional and linear layers (same for all layers).

  • membrane_subtract – Value subtracted from the potential upon spiking for convolutional and linear layers (same for all layers).

  • bias_rescaling – Biases are divided by this value.

  • synops – If True (default), register hooks for counting synaptic operations during foward passes.

  • add_spiking_output – If True (default: False), add a spiking layer to the end of a sequential model if not present.