spikingjelly.activation_based.layer package#
备注
API稳定性说明
SpikingJelly 0.0.0.1.0 对 layer 模块的内部实现进行了重构:原来的 layer.py 文件已被拆分并重组为 layer/ 包,以提升代码的模块化程度和可维护性。
该改动不会影响对外公开的 API。 我们强烈建议用户仍然通过 layer 这一顶层命名空间来访问相关功能,而不是从具体的内部子模块中进行导入。 layer 层级下的导入路径被视为稳定的公共接口;更深层的子模块仅作为内部实现细节,未来可能发生变化。
from spikingjelly.activation_based.layer import SeqToANNContainer # 推荐 ✅
from spikingjelly.activation_based.layer.container import SeqToANNContainer # 不推荐 ❌
API Stability Notice
We have refactored the internal implementation of the layer module. The original layer.py file has been reorganized into a package ( layer/ ) for better modularity and maintainability.
This change does not affect the public API. Users are strongly encouraged to continue accessing layers directly from the layer namespace, rather than importing from specific internal submodules. Import paths under layer are considered part of the stable public API, while deeper submodule paths are treated as implementation details and may change in future releases.
from spikingjelly.activation_based.layer import SeqToANNContainer # recommended ✅
from spikingjelly.activation_based.layer.container import SeqToANNContainer # not recommended ❌
Containers#
SpikingJelly 的 容器 封装了常见的网络结构,并支持单步(s)和多步(m)步进模式。
SpikingJelly's containers wrap common network architectures and support both single-step (s) and multi-step (m) step modes.
Container for multi-step forward pass. |
|
Container that merges the time and batch dimensions for forward pass. |
|
Multi-step container whose time dimension is placed at the last. |
|
SeqToANNContainer whose time dimension is placed at the last. |
|
Container that sets the step mode for all contained modules. |
|
Container for element-wise recurrent connections. |
|
Container for linear recurrent connections. |
Wrappers for Stateless Layers#
SpikingJelly 的 无状态层包装器 封装了 PyTorch 的标准层,并支持脉冲神经网络的时间步进模式。
SpikingJelly's stateless layer wrappers wrap PyTorch's standard layers and support the step mode of Spiking Neural Networks.
Convolutional Layers#
Convolutional Transpose Layers#
1D transposed convolution layer with step mode support. |
|
2D transposed convolution layer with step mode support. |
|
3D transposed convolution layer with step mode support. |
Upsampling Layers#
Upsampling layer with configurable interpolation methods. |
Pooling Layers#
1D max pooling layer with step mode support. |
|
2D max pooling layer with step mode support. |
|
3D max pooling layer with step mode support. |
|
1D average pooling layer with step mode support. |
|
2D average pooling layer with step mode support. |
|
3D average pooling layer with step mode support. |
|
1D adaptive average pooling layer with step mode support. |
|
2D adaptive average pooling layer with step mode support. |
|
3D adaptive average pooling layer with step mode support. |
Linear Layers#
Layers with Weight Standardization#
Group Normalization Layers#
Group normalization layer with step mode support. |
Attention Layers#
SpikingJelly 的 注意力层 提供了用于深度脉冲神经网络的注意力机制实现,包括用于卷积 SNN 的注意力层和用于脉冲 Transformers 的注意力层。
SpikingJelly's attention layers provide attention mechanisms for deep Spiking Neural Networks, including attention layers for convolutional SNNs and Spiking Transformers.
Attention for Convolutional SNNs#
Temporal-wise attention. |
|
Multi-dimensional attention. |
Attention for Spiking Transformers#
Spiking self-attention for Spikformer. |
|
Query-Key attention for QKFormer. |
|
Token-wise Query-Key attention for QKFormer. |
|
Channel-wise Query-Key attention for QKFormer. |
Batch Normalization Variants#
SpikingJelly 提供了多种适用于深度 SNN 的 批归一化层变体 。
SpikingJelly provides multiple batch normalization variants that are optimized for deep SNNs.
Standard Batch Normalization#
1D batch normalization layer with step mode support. |
|
2D batch normalization layer with step mode support. |
|
3D batch normalization layer with step mode support. |
NeuNorm#
Neural Normalization layer. |
Threshold-Dependent Batch Normalization#
1D threshold-dependent batch normalization layer. |
|
2D threshold-dependent batch normalization layer. |
|
3D threshold-dependent batch normalization layer. |
Temporal Effective Batch Normalization#
1D temporal effective batch normalization layer. |
|
2D temporal effective batch normalization layer. |
|
3D temporal effective batch normalization layer. |
Batch Normalization Through Time#
1D batch normalization through time. |
|
2D batch normalization through time. |
|
3D batch normalization through time. |
Dropout Variants#
SpikingJelly 提供了适用于 SNN 的 Dropout 实现,支持步进模式。
SpikingJelly provides dropout implementations suitable for SNNs with step mode support.
Dropout layer with step mode support. |
|
2D dropout layer with step mode support. |
|
DropConnect linear layer with step mode support. |
Online Learning Modules#
SpikingJelly 的 在线学习模块 提供了用于在线学习的辅助类和操作。
SpikingJelly's online learning modules provide auxiliary classes and operations for online learning.
AutoGrad function for gradient replacement. |
|
Computing gradients using neuron traces. |
|
Operation for spike and trace handling in online training. |
|
Sequential container for online training through time. |
Miscellaneous#
SpikingJelly 的 杂项模块 提供了辅助层和其他实用工具。
SpikingJelly's miscellaneous module provides auxiliary layers and other utilities.
Synapse filter layer with exponential decay. |
|
Module for printing input shapes during forward pass. |
|
Voting layer for multi-class classification. |
|
Temporal delay operation. |