spikingjelly.clock_driven.ann2snn package¶
Subpackages¶
Submodules¶
spikingjelly.clock_driven.ann2snn.modules module¶
- class spikingjelly.clock_driven.ann2snn.modules.MaxPool2d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False, momentum=None)[源代码]¶
基类:
torch.nn.modules.module.Module
- 参数
kernel_size – 窗口取最大的大小
stride – 窗口的步长. 默认值为
kernel_size
padding – 隐式两侧填充零的大小
dilation – 控制窗口中元素的步幅的参数
return_indices – 当
True
,将返回最大序号并输出ceil_mode – 当
True
,将使用 ceil 而不是 floor 来计算输出形状momentum – 当在[0,1]中,将在门控函数中使用在线动量统计; 当为
None
时,将在门控函数中使用累计脉冲数
- 返回
None
基于文献 1 中2.2.6章节设计MaxPool2d模块。为了兼容Pytorch的MaxPool2d模块,众多参数设定和Pytorch相同。详情请见
torch.nn.MaxPool2d
。 基本想法是对输入脉冲进行统计,统计量可以控制门控函数确定以哪一路输入信号作为输出。 根据 momentum 参数类型不同可以有不同的统计功能。 momentum 参数支持None值和[0,1]区间的浮点数数值作为输出。 假定在t时刻,脉冲输入张量为 \(s_t\) ,脉冲统计量为 \(p_t\) 当 momentum 参数为None
时,统计量为累计脉冲数\[p_t = p_{t-1} + s_t\]当 momentum 参数为[0,1]区间的浮点数时,统计量为在线的动量累积
\[p_t = momentum * p_{t-1} + (1-momentum) * s_t\]- 参数
kernel_size – the size of the window to take a max over
stride – the stride of the window. Default value is
kernel_size
padding – implicit zero padding to be added on both sides
dilation – a parameter that controls the stride of elements in the window
return_indices – if
True
, will return the max indices along with the outputs. Useful fortorch.nn.MaxUnpool2d
laterceil_mode – when
True
, will use ceil instead of floor to compute the output shapemomentum – when in [0,1], will use online momentum statistics in gate functions; when
None
, will use accumulated spike in gate functions
- 返回
None
Design the MaxPool2d module based on section 2.2.6 in 1 . In order to be compatible with Pytorch’s MaxPool2d module, many parameter settings are the same as Pytorch. See
torch.nn.MaxPool2d
for details. The basic idea is to accumulate the input spikes, which can control the gating function to determine which input spike is used as output. Depending on the type of momentum parameter, different statistical functions can be used. momentum supports the floating-point value in [0,1] or valueNone
Assume at time t, the spike input is \(s_t\) and the spike statistic is \(p_t\). When momentum isNone
, the statistic is sum of spikes over time.\[p_t = p_{t-1} + s_t\]When momentum is a floating point in [0,1], the statistic is online momentum of spikes.
\[p_t = momentum * p_{t-1} + (1-momentum) * s_t\]- 1(1,2)
Rueckauer B, Lungu I-A, Hu Y, Pfeiffer M and Liu S-C (2017) Conversion of Continuous-Valued Deep Networks to
Efficient Event-Driven Networks for Image Classification. Front. Neurosci. 11:682.
- forward(dv: torch.Tensor)[源代码]¶
Module contents¶
- class spikingjelly.clock_driven.ann2snn.parser(name='', kernel='onnx', **kargs)[源代码]¶
基类:
object
- parse(model: torch.nn.modules.module.Module, data: torch.Tensor, **kargs) → torch.nn.modules.module.Module[源代码]¶
- spikingjelly.clock_driven.ann2snn.z_norm_integration(model: torch.nn.modules.module.Module, z_norm=None) → torch.nn.modules.module.Module[源代码]¶