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.0functional 模块的内部实现进行了重构:原来的 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_net

Reset the state of a network.

set_step_mode

Set the step mode for a network.

set_backend

Set the computational backend for a network.

detach_net

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.

multi_step_forward

Forward pass for stateful modules in multi-step mode.

t_last_multi_step_forward

Multi-step forward. The time dimension is placed at the last.

chunk_multi_step_forward

Multi-step forward pass with chunked processing.

seq_to_ann_forward

Forward pass for stateless modules in multi-step mode.

t_last_seq_to_ann_forward

Seq-to-ann forward. The time dimension is placed at the last.

Loss Functions#

适用于 SNN 的 损失函数 实现。


Loss functions suitable for SNNs.

kernel_dot_product

Kernel dot product implementation.

spike_similar_loss

Spike similarity loss.

temporal_efficient_training_cross_entropy

TET loss.

Online Learning Pipelines#

在线学习 的辅助函数。


Auxiliary functions for online learning .

fptt_online_training_init_w_ra

Initialize weight for FPTT.

fptt_online_training

Online training with FPTT.

ottt_online_training

Online training with OTTT or SLTT.

Miscellaneous#

其他辅助 工具函数


Other auxiliary tool functions .

set_threshold_margin

Set the threshold margin for classification layers.

redundant_one_hot

Convert labels to redundant one-hot encoding.

first_spike_index

Find the index of the first spike in a spike train.

kaiming_normal_conv_linear_weight

Initialize weights with Kaiming Normal initialization.

delay

y[t] = x[t - delay_steps] .