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. See Basic Conception for more details.

class spikingjelly.activation_based.layer.stateless_wrapper.Conv1d(in_channels: int, out_channels: int, kernel_size: int | tuple[int], stride: int | tuple[int] = 1, padding: str | int | tuple[int] = 0, dilation: int | tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', step_mode: str = 's')[源代码]#

基类:Conv1d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.Conv1d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.Conv1d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.Conv2d(in_channels: int, out_channels: int, kernel_size: int | tuple[int, int], stride: int | tuple[int, int] = 1, padding: str | int | tuple[int, int] = 0, dilation: int | tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', step_mode: str = 's')[源代码]#

基类:Conv2d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.Conv2d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.Conv2d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.Conv3d(in_channels: int, out_channels: int, kernel_size: int | tuple[int, int, int], stride: int | tuple[int, int, int] = 1, padding: str | int | tuple[int, int, int] = 0, dilation: int | tuple[int, int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', step_mode: str = 's')[源代码]#

基类:Conv3d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.Conv3d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.Conv3d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.Upsample(size: int | tuple[int, ...] | None = None, scale_factor: float | tuple[float, ...] | None = None, mode: str = 'nearest', align_corners: bool | None = None, recompute_scale_factor: bool | None = None, step_mode: str = 's')[源代码]#

基类:Upsample, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.Upsample


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.Upsample for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor) Tensor[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.ConvTranspose1d(in_channels: int, out_channels: int, kernel_size: int | tuple[int], stride: int | tuple[int] = 1, padding: int | tuple[int] = 0, output_padding: int | tuple[int] = 0, groups: int = 1, bias: bool = True, dilation: int | tuple[int] = 1, padding_mode: str = 'zeros', step_mode: str = 's')[源代码]#

基类:ConvTranspose1d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.ConvTranspose1d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.ConvTranspose1d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.ConvTranspose2d(in_channels: int, out_channels: int, kernel_size: int | tuple[int, int], stride: int | tuple[int, int] = 1, padding: int | tuple[int, int] = 0, output_padding: int | tuple[int, int] = 0, groups: int = 1, bias: bool = True, dilation: int = 1, padding_mode: str = 'zeros', step_mode: str = 's')[源代码]#

基类:ConvTranspose2d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.ConvTranspose2d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.ConvTranspose2d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.ConvTranspose3d(in_channels: int, out_channels: int, kernel_size: int | tuple[int, int, int], stride: int | tuple[int, int, int] = 1, padding: int | tuple[int, int, int] = 0, output_padding: int | tuple[int, int, int] = 0, groups: int = 1, bias: bool = True, dilation: int | tuple[int, int, int] = 1, padding_mode: str = 'zeros', step_mode: str = 's')[源代码]#

基类:ConvTranspose3d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.ConvTranspose3d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.ConvTranspose3d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.GroupNorm(num_groups: int, num_channels: int, eps: float = 1e-05, affine: bool = True, step_mode='s')[源代码]#

基类:GroupNorm, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.GroupNorm


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.GroupNorm for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.MaxPool1d(kernel_size: int | tuple[int], stride: int | tuple[int] | None = None, padding: int | tuple[int] = 0, dilation: int | tuple[int] = 1, return_indices: bool = False, ceil_mode: bool = False, step_mode='s')[源代码]#

基类:MaxPool1d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.MaxPool1d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.MaxPool1d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.MaxPool2d(kernel_size: int | tuple[int, int], stride: int | tuple[int, int] | None = None, padding: int | tuple[int, int] = 0, dilation: int | tuple[int, int] = 1, return_indices: bool = False, ceil_mode: bool = False, step_mode='s')[源代码]#

基类:MaxPool2d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.MaxPool2d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.MaxPool2d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.MaxPool3d(kernel_size: int | tuple[int, int, int], stride: int | tuple[int, int, int] | None = None, padding: int | tuple[int, int, int] = 0, dilation: int | tuple[int, int, int] = 1, return_indices: bool = False, ceil_mode: bool = False, step_mode='s')[源代码]#

基类:MaxPool3d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.MaxPool3d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.MaxPool3d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.AvgPool1d(kernel_size: int | tuple[int], stride: int | tuple[int] = None, padding: int | tuple[int] = 0, ceil_mode: bool = False, count_include_pad: bool = True, step_mode='s')[源代码]#

基类:AvgPool1d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.AvgPool1d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.AvgPool1d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.AvgPool2d(kernel_size: int | tuple[int, int], stride: int | tuple[int, int] | None = None, padding: int | tuple[int, int] = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int | None = None, step_mode='s')[源代码]#

基类:AvgPool2d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.AvgPool2d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.AvgPool2d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.AvgPool3d(kernel_size: int | tuple[int, int, int], stride: int | tuple[int, int, int] | None = None, padding: int | tuple[int, int, int] = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int | None = None, step_mode='s')[源代码]#

基类:AvgPool3d, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.AvgPool3d


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.AvgPool3d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.AdaptiveAvgPool1d(output_size, step_mode='s')[源代码]#

基类:AdaptiveAvgPool1d, StepModule

API Language: 中文 | English


  • 中文

  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.AdaptiveAvgPool1d


  • English

  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.AdaptiveAvgPool1d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.AdaptiveAvgPool2d(output_size, step_mode='s')[源代码]#

基类:AdaptiveAvgPool2d, StepModule

API Language: 中文 | English


  • 中文

  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.AdaptiveAvgPool2d


  • English

  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.AdaptiveAvgPool2d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.AdaptiveAvgPool3d(output_size, step_mode='s')[源代码]#

基类:AdaptiveAvgPool3d, StepModule

API Language: 中文 | English


  • 中文

  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.AdaptiveAvgPool3d


  • English

  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.AdaptiveAvgPool3d for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.Linear(in_features: int, out_features: int, bias: bool = True, step_mode='s')[源代码]#

基类:Linear, StepModule

API Language: 中文 | English


  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.Linear


  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.Linear for other parameters' API

返回:

None

返回类型:

None

class spikingjelly.activation_based.layer.stateless_wrapper.Flatten(start_dim: int = 1, end_dim: int = -1, step_mode='s')[源代码]#

基类:Flatten, StepModule

API Language: 中文 | English


  • 中文

  • 中文

参数:

step_mode (str) -- 步进模式,可以为 's' (单步) 或 'm' (多步)

其他的参数API参见 torch.nn.Flatten


  • English

  • English

参数:

step_mode (str) -- the step mode, which can be s (single-step) or m (multi-step)

Refer to torch.nn.Flatten for other parameters' API

返回:

None

返回类型:

None

forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.WSConv2d(in_channels: int, out_channels: int, kernel_size: int | tuple[int, int], stride: int | tuple[int, int] = 1, padding: str | int | tuple[int, int] = 0, dilation: int | tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', step_mode: str = 's', gain: bool = True, eps: float = 0.0001)[源代码]#

基类:Conv2d

API Language: 中文 | English


  • 中文

参数:
  • gain (bool) -- 是否对权重引入可学习的缩放系数

  • eps (float) -- 预防数值问题的小量

其他的参数API参见 Conv2d


  • English

参数:
  • gain -- whether introduce learnable scale factors for weights

  • eps (float) -- a small number to prevent numerical problems

Refer to Conv2d for other parameters' API

返回:

None

返回类型:

None

get_weight()[源代码]#
forward(x: Tensor)[源代码]#
class spikingjelly.activation_based.layer.stateless_wrapper.WSLinear(in_features: int, out_features: int, bias: bool = True, step_mode='s', gain=True, eps=0.0001)[源代码]#

基类:Linear

API Language: 中文 | English


  • 中文

参数:
  • gain (bool) -- 是否对权重引入可学习的缩放系数

  • eps (float) -- 预防数值问题的小量

其他的参数API参见 Linear


  • English

参数:
  • gain -- whether introduce learnable scale factors for weights

  • eps (float) -- a small number to prevent numerical problems

Refer to Linear for other parameters' API

返回:

None

返回类型:

None

get_weight()[源代码]#
forward(x: Tensor)[源代码]#