spikingjelly.activation_based.functional package#
警告
卷积-批归一化融合函数已弃用。用户可以使用 PyTorch的fuse_conv_bn_eval 来实现相同的功能。
Functions for conv-bn fusion have been deprecated. Use PyTorch's fuse_conv_bn_eval to achieve the same functionality.
备注
API稳定性说明
SpikingJelly 0.0.0.1.0 对 functional 模块的内部实现进行了重构:原来的 functional.py 文件已被拆分并重组为 functional/ 包,以提升代码的模块化程度和可维护性。
该改动不会影响对外公开的 API。 我们强烈建议用户仍然通过 functional 这一顶层命名空间来访问相关功能,而不是从具体的内部子模块中进行导入。 functional 层级下的导入路径被视为稳定的公共接口;更深层的子模块仅作为内部实现细节,未来可能发生变化。
from spikingjelly.activation_based.functional import reset_net # 推荐 ✅
from spikingjelly.activation_based.functional.net_config import reset_net # 不推荐 ❌
API Stability Notice
We have refactored the internal implementation of the functional module. The original functional.py file has been reorganized into a package ( functional/ ) for better modularity and maintainability.
This change does not affect the public API. Users are strongly encouraged to continue accessing layers directly from the functional namespace, rather than importing from specific internal submodules. Import paths under functional 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.functional import reset_net # recommended ✅
from spikingjelly.activation_based.functional.net_config import reset_net # not recommended ❌
Network Configuration Functions#
这些函数帮助用户统一设置网络中每个 子模块的配置 ,如步进模式、后端等。
These functions help users set configurations for each submodule in a network, such as step mode and backend.
|
Reset the state of a network. |
|
Set the step mode for a network. |
|
Set the computational backend for a network. |
|
Detach the network's parameters from the computation graph. |
Forward Functions#
SpikingJelly 的 前向传播函数 实现了 SNN 的多步前向传播逻辑。
SpikingJelly's forward functions provide multi-step forward propagation logic for SNNs.
Forward pass for stateful modules in multi-step mode. |
|
Multi-step forward. The time dimension is placed at the last. |
|
Multi-step forward pass with chunked processing. |
|
Forward pass for stateless modules in multi-step mode. |
|
Seq-to-ann forward. The time dimension is placed at the last. |
Neuron State Updates#
这些函数显式接收并返回神经元状态。*_step 表示一个时间步的完整更新;
*_multi_step 表示具有独立实现的时间序列更新,而不是对 *_step 的 Python
循环包装。backend 仍由 MemoryModule 选择,因此 backend 专用函数在名称中
标出 cupy 或 triton。
These functions receive and return neuron states explicitly. *_step denotes
one complete time-step update. *_multi_step denotes an independently implemented
sequence update, not a Python-loop wrapper around *_step. Backend selection
remains a MemoryModule responsibility, so backend-specific functions identify
cupy or triton in their names.
|
One IF state update. |
|
One QIF state update. |
|
One EIF state update. |
|
One LIF state update. |
|
One ParametricLIF state update. |
|
One Izhikevich voltage and adaptation-current update. |
|
One KLIF state update. |
|
One current-based LIF state update. |
|
One Lava-compatible quantized CUBA-LIF state update. |
|
One ActivationAwareIF state update. |
|
One SlidingPSN queue update. |
|
One GatedLIF state update. |
|
One SpikeZIP STBIF state update. |
|
One IF update with caller-selected CuPy kernels. |
|
One LIF update with caller-selected CuPy kernels. |
|
IF sequence update with CuPy. |
|
LIF sequence update with CuPy. |
|
ParametricLIF sequence update with CuPy. |
|
QIF sequence update with CuPy. |
|
EIF sequence update with CuPy. |
|
Izhikevich sequence update with CuPy. |
|
IF sequence update with Triton. |
|
LIF sequence update with Triton. |
|
ParametricLIF sequence update with Triton. |
|
ActivationAwareIF sequence update with Triton. |
Stateful Layer Updates#
这些函数显式接收并返回 stateful layer 的局部状态,不读取 MemoryModule 的隐式
memory。
These functions receive and return local state for stateful layers explicitly.
They do not read implicit MemoryModule memory.
One Delay queue update. |
|
One SynapseFilter state update. |
Loss Functions#
适用于 SNN 的 损失函数 实现。
Loss functions suitable for SNNs.
Kernel dot product implementation. |
|
Spike similarity loss. |
|
TET loss. |
Learning State Transition Functions#
这些函数显式接收 STDP/mSTDP/mSTDP-ET 的 trace、eligibility、reward 和 raw
权重 tensor,不读取 monitor、MemoryModule memory,也不负责 step_mode、
training/eval 或梯度写入。
These functions receive STDP/mSTDP/mSTDP-ET traces, eligibility, reward, and
raw weight tensors explicitly. They do not read monitors or MemoryModule
memory, and do not manage step_mode, training/eval, or gradient writes.
Tensor-only linear STDP single-step update. |
|
Tensor-only Conv1d STDP single-step update. |
|
Tensor-only Conv2d STDP single-step update. |
|
Tensor-only linear mSTDP eligibility update. |
|
Tensor-only linear mSTDP-ET eligibility update. |
|
Eligibility-trace decay and reward modulation for mSTDP-ET. |
Online Learning Pipelines#
在线学习 的辅助函数。
Auxiliary functions for online learning .
|
Initialize weight for FPTT. |
|
Online training with FPTT. |
|
Online training with OTTT or SLTT. |
Miscellaneous#
其他辅助 工具函数 。
Other auxiliary tool functions .
|
Set the threshold margin for classification layers. |
|
Convert labels to redundant one-hot encoding. |
|
Find the index of the first spike in a spike train. |
|
Initialize weights with Kaiming Normal initialization. |
|
|