qualia_plugin_snn.learningframework package
Submodules
- qualia_plugin_snn.learningframework.SpikingJelly module
- qualia_plugin_snn.learningframework.SpikingJellyMultiStep module
- qualia_plugin_snn.learningframework.SpikingJellyMultiStepTimeStepsInData module
- qualia_plugin_snn.learningframework.SpikingJellyTimeStepsInData module
Module contents
Qualia-Plugin-SNN learningframework package contains the SpikingJelly interface to use with the bundled learningmodels.
- class qualia_plugin_snn.learningframework.SpikingJelly[source]
Bases:
PyTorchSpikingJelly single-step LearningFramework implementation extending PyTorch.
qualia_core.learningframework.PyTorch.PyTorch.learningmodelsare replaced by the Spiking Neural Networks fromqualia_plugin_snn.learningmodel.pytorch- experimenttrackings: ModuleType
qualia_plugin_snn.experimenttracking.pytorchadditional experimenttrackings for Spiking Neural Networks.Merged to
qualia_core.learningframework.PyTorch.PyTorch.experimenttrackings.
- learningmodels: ModuleType
qualia_plugin_snn.learningmodel.pytorchadditional learningmodels for Spiking Neural Networks.
- class TrainerModule[source]
Bases:
TrainerModuleSpikingJelly single-step TrainerModule implementation extending PyTorch TrainerModule.
- forward(x: Tensor) Tensor[source]
Forward pass for a Spiking Neural Network model with duplicated timesteps.
First calls SpikingJelly’s reset on the model to reset neurons potentials. Then duplicate the input to generate the number of timesteps given by
qualia_plugin_snn.learningmodel.pytorch.SNN.SNN.timestepsCallqualia_plugin_snn.learningmodel.pytorch.SNN.SNN.forward()for each timestep. Finally, average the output of the model over the timesteps.
- class qualia_plugin_snn.learningframework.SpikingJellyMultiStep[source]
Bases:
SpikingJellySpikingJelly multi-step LearningFramework implementation extending SpikingJelly single-step.
- class TrainerModule[source]
Bases:
TrainerModuleSpikingJelly multi-step TrainerModule implementation extending SpikingJelly single-step TrainerModule.
- forward(x: Tensor) Tensor[source]
Forward pass for a Spiking Neural Network model with duplicated timesteps in multi-step mode.
First calls SpikingJelly’s reset on the model to reset neurons potentials. Then duplicate the input to generate the number of timesteps given by
qualia_plugin_snn.learningmodel.pytorch.SNN.SNN.timesteps. Timesteps are generated as a new dimension of the input tensor: [N, C, …] → [T, N, C, …] Callqualia_plugin_snn.learningmodel.pytorch.SNN.SNN.forward()for the whole tensor. Finally, average the output of the model over the timestep dimension.
- class qualia_plugin_snn.learningframework.SpikingJellyMultiStepTimeStepsInData[source]
Bases:
SpikingJellyTimeStepsInDataSpikingJelly multi-step with timesteps in data LearningFramework implementation extending SpikingJelly single-step.
- class TrainerModule[source]
Bases:
TrainerModuleSpikingJelly multi-step with timesteps in data TrainerModule extending SpikingJelly single-step TrainerModule.
- forward(x: Tensor) Tensor[source]
Forward pass for a Spiking Neural Network model with timesteps in input data in multi-step mode.
First calls SpikingJelly’s reset on the model to reset neurons potentials. Call
qualia_plugin_snn.learningmodel.pytorch.SNN.SNN.forward()for each timestep of the input data. Finally, average the output of the model over the timesteps.- Parameters:
x (Tensor) – Input data with timestep dimension in [N, T, C, S] or [N, T, C, H, W] order
- Returns:
Output predictions
- Raises:
ValueError – when the input data does not have the correct number of dimenions or the timestep dimension does not match
qualia_plugin_snn.learningmodel.pytorch.SNN.SNN.timesteps- Return type:
- class qualia_plugin_snn.learningframework.SpikingJellyTimeStepsInData[source]
Bases:
SpikingJellySpikingJelly single-step with timesteps in data LearningFramework implementation extending SpikingJelly single-step.
- class TrainerModule[source]
Bases:
TrainerModuleSpikingJelly single-step with timesteps in data TrainerModule extending SpikingJelly single-step TrainerModule.
- apply_dataaugmentation(batch: tuple[Tensor, Tensor], dataaugmentation: DataAugmentationPyTorch) tuple[Tensor, Tensor][source]
Call a dataaugmentation module on the current batch.
If the dataaugmentation module is not a
qualia_plugin_snn.dataaugmentation.pytorch.DataAugmentationPyTorchTimeStepsInData, or ifqualia_plugin_snn.dataaugmentation.pytorch.DataAugmentationPyTorchTimeStepsInData.collapse_timestepsisTrue, then the timestep dimension is automatically merged with the batch dimension in order to support existing non-timestep-aware Qualia-Core dataaugmentation modules transparently.
- forward(x: Tensor) Tensor[source]
Forward pass for a Spiking Neural Network model with timesteps in input data in single-step mode.
First calls SpikingJelly’s reset on the model to reset neurons potentials. Call
qualia_plugin_snn.learningmodel.pytorch.SNN.SNN.forward()for each timestep of the input data. Finally, average the output of the model over the timesteps.- Parameters:
x (Tensor) – Input data with timestep dimension in [N, T, C, S] or [N, T, C, H, W] order
- Returns:
Output predictions
- Raises:
ValueError – when the input data does not have the correct number of dimenions or the timestep dimension does not match
qualia_plugin_snn.learningmodel.pytorch.SNN.SNN.timesteps- Return type:
- static channels_last_to_channels_first(x: ndarray[Any, Any]) ndarray[Any, Any][source]
Channels last to channels first conversion with consideration of timestep dimension.
For 2D data with timestep: [N, T, H, W, C] → [N, T, C, H, W]
For 1D data with timestep: [N, T, S, C] → [N, T, C, S]
- static channels_first_to_channels_last(x: ndarray[Any, Any]) ndarray[Any, Any][source]
Channels first to channels last conversion with consideration of timestep dimension.
For 2D data with timestep: [N, T, C, H, W] → [N, T, H, W, C]
For 1D data with timestep: [N, T, C, S] → [N, T, S, C]