spikingjelly.activation_based.base package
Module contents
- spikingjelly.activation_based.base.check_backend_library(backend: str)[源代码]
-
- 参数:
backend (str) –
'torch'
,'cupy'
或'lava'
检查某个后端的python库是否已经安装。若未安装则此函数会报错。
- 参数:
backend (str) –
'torch'
,'cupy'
or'lava'
Check whether the python lib for backend is installed. If not, this function will raise an error.
- class spikingjelly.activation_based.base.StepModule[源代码]
基类:
object
- property step_mode
-
- 返回:
模块当前使用的步进模式
- 返回类型:
- 返回:
the current step mode of this module
- 返回类型:
- class spikingjelly.activation_based.base.SingleModule[源代码]
基类:
StepModule
只支持单步的模块 (
step_mode == 's'
)。The module that only supports for single-step (
step_mode == 's'
)
- class spikingjelly.activation_based.base.MultiStepModule[源代码]
基类:
StepModule
只支持多步的模块 (
step_mode == 'm'
)。The module that only supports for multi-step (
step_mode == 'm'
)
- class spikingjelly.activation_based.base.MemoryModule[源代码]
基类:
Module
,StepModule
MemoryModule
是SpikingJelly中所有有状态(记忆)模块的基类。MemoryModule
is the base class of all stateful modules in SpikingJelly.- property supported_backends
-
返回支持的后端,默认情况下只有 (‘torch’, )
Return the supported backends. The default return value is (‘torch’, )
- property backend
- abstract single_step_forward(x: Tensor, *args, **kwargs)[源代码]
-
- 参数:
x (torch.Tensor) – input tensor with ``shape = [N, *] ``
本模块的单步的前向传播函数
- 参数:
x (torch.Tensor) – input tensor with ``shape = [N, *] ``
The single-step forward function for this module
- multi_step_forward(x_seq: Tensor, *args, **kwargs)[源代码]
-
- 参数:
x_seq (torch.Tensor) – input tensor with ``shape = [T, N, *] ``
本模块的多步的前向传播函数,通过调用
T
次single_step_forward(x[t], *args, **kwargs)
实现- 参数:
x_seq (torch.Tensor) – input tensor with ``shape = [T, N, *] ``
The multi-step forward function for this module, which is implemented by calling
single_step_forward(x[t], *args, **kwargs)
overT
times
- register_memory(name: str, value)[源代码]
-
- 参数:
name (str) – 变量的名字
value (any) – 变量的值
将变量存入用于保存有状态变量(例如脉冲神经元的膜电位)的字典中。这个变量的重置值会被设置为
value
。每次调用self.reset()
函数后,self.name
都会被重置为value
。- 参数:
name (str) – variable’s name
value (any) – variable’s value
Register the variable to memory dict, which saves stateful variables (e.g., the membrane potential of a spiking neuron). The reset value of this variable will be
value
.self.name
will be set tovalue
after each calling ofself.reset()
.
- memories()[源代码]
-
- 返回:
返回一个所有状态变量的迭代器
- 返回类型:
Iterator
- 返回:
an iterator over all stateful variables
- 返回类型:
Iterator
- named_memories()[源代码]
-
- 返回:
返回一个所有状态变量及其名称的迭代器
- 返回类型:
Iterator
- 返回:
an iterator over all stateful variables and their names
- 返回类型:
Iterator