spikingjelly.activation_based.model package

Submodules

spikingjelly.activation_based.model.parametric_lif_net module

class spikingjelly.activation_based.model.parametric_lif_net.MNISTNet(channels=128, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]

基类:Module

forward(x: Tensor)[源代码]
training: bool
class spikingjelly.activation_based.model.parametric_lif_net.FashionMNISTNet(channels=128, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]

基类:MNISTNet

training: bool
class spikingjelly.activation_based.model.parametric_lif_net.NMNISTNet(channels=128, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]

基类:MNISTNet

training: bool
class spikingjelly.activation_based.model.parametric_lif_net.CIFAR10Net(channels=256, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]

基类:Module

forward(x)[源代码]
training: bool
class spikingjelly.activation_based.model.parametric_lif_net.CIFAR10DVSNet(channels=128, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]

基类:Module

forward(x: Tensor)[源代码]
training: bool
class spikingjelly.activation_based.model.parametric_lif_net.DVSGestureNet(channels=128, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]

基类:Module

forward(x: Tensor)[源代码]
training: bool

spikingjelly.activation_based.model.sew_resnet module

class spikingjelly.activation_based.model.sew_resnet.SEWResNet(block, layers, num_classes=1000, zero_init_residual=False, groups=1, width_per_group=64, replace_stride_with_dilation=None, norm_layer=None, cnf: Optional[str] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]

基类:Module

forward(x)[源代码]
training: bool
spikingjelly.activation_based.model.sew_resnet.sew_resnet18(pretrained=False, progress=True, cnf: Optional[str] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • cnf (str) – the name of spike-element-wise function

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNet-18

返回类型:

torch.nn.Module

The spike-element-wise ResNet-18 “Deep Residual Learning in Spiking Neural Networks” modified by the ResNet-18 model from “Deep Residual Learning for Image Recognition”

spikingjelly.activation_based.model.sew_resnet.sew_resnet34(pretrained=False, progress=True, cnf: Optional[str] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • cnf (str) – the name of spike-element-wise function

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNet-34

返回类型:

torch.nn.Module

The spike-element-wise ResNet-34 “Deep Residual Learning in Spiking Neural Networks” modified by the ResNet-34 model from “Deep Residual Learning for Image Recognition”

spikingjelly.activation_based.model.sew_resnet.sew_resnet50(pretrained=False, progress=True, cnf: Optional[str] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • cnf (str) – the name of spike-element-wise function

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNet-50

返回类型:

torch.nn.Module

The spike-element-wise ResNet-50 “Deep Residual Learning in Spiking Neural Networks” modified by the ResNet-50 model from “Deep Residual Learning for Image Recognition”

spikingjelly.activation_based.model.sew_resnet.sew_resnet101(pretrained=False, progress=True, cnf: Optional[str] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • cnf (str) – the name of spike-element-wise function

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNet-101

返回类型:

torch.nn.Module

The spike-element-wise ResNet-101 “Deep Residual Learning in Spiking Neural Networks” modified by the ResNet-101 model from “Deep Residual Learning for Image Recognition”

spikingjelly.activation_based.model.sew_resnet.sew_resnet152(pretrained=False, progress=True, cnf: Optional[str] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • cnf (str) – the name of spike-element-wise function

  • spiking_neuron (callable) – a single step neuron

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNet-152

返回类型:

torch.nn.Module

The spike-element-wise ResNet-152 “Deep Residual Learning in Spiking Neural Networks” modified by the ResNet-152 model from “Deep Residual Learning for Image Recognition”

spikingjelly.activation_based.model.sew_resnet.sew_resnext50_32x4d(pretrained=False, progress=True, cnf: Optional[str] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • cnf (str) – the name of spike-element-wise function

  • spiking_neuron (callable) – a single step neuron

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNeXt-50 32x4d

返回类型:

torch.nn.Module

The spike-element-wise ResNeXt-50 32x4d “Deep Residual Learning in Spiking Neural Networks” modified by the ResNeXt-50 32x4d model from “Aggregated Residual Transformation for Deep Neural Networks”

spikingjelly.activation_based.model.sew_resnet.sew_resnext101_32x8d(pretrained=False, progress=True, cnf: Optional[str] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • cnf (str) – the name of spike-element-wise function

  • spiking_neuron (callable) – a single step neuron

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNeXt-101 32x8d

返回类型:

torch.nn.Module

The spike-element-wise ResNeXt-101 32x8d “Deep Residual Learning in Spiking Neural Networks” modified by the ResNeXt-101 32x8d model from “Aggregated Residual Transformation for Deep Neural Networks”

spikingjelly.activation_based.model.sew_resnet.sew_wide_resnet50_2(pretrained=False, progress=True, cnf: Optional[str] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • cnf (str) – the name of spike-element-wise function

  • spiking_neuron (callable) – a single step neuron

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking Wide ResNet-50-2

返回类型:

torch.nn.Module

The spike-element-wise Wide ResNet-50-2 “Deep Residual Learning in Spiking Neural Networks” modified by the Wide ResNet-50-2 model from “Wide Residual Networks”

The model is the same as ResNet except for the bottleneck number of channels which is twice larger in every block. The number of channels in outer 1x1 convolutions is the same, e.g. last block in ResNet-50 has 2048-512-2048 channels, and in Wide ResNet-50-2 has 2048-1024-2048.

spikingjelly.activation_based.model.sew_resnet.sew_wide_resnet101_2(pretrained=False, progress=True, cnf: Optional[str] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • cnf (str) – the name of spike-element-wise function

  • spiking_neuron (callable) – a single step neuron

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking Wide ResNet-101-2

返回类型:

torch.nn.Module

The spike-element-wise Wide ResNet-101-2 “Deep Residual Learning in Spiking Neural Networks” modified by the Wide ResNet-101-2 model from “Wide Residual Networks”

The model is the same as ResNet except for the bottleneck number of channels which is twice larger in every block. The number of channels in outer 1x1 convolutions is the same, e.g. last block in ResNet-50 has 2048-512-2048 channels, and in Wide ResNet-50-2 has 2048-1024-2048.

spikingjelly.activation_based.model.spiking_resnet module

class spikingjelly.activation_based.model.spiking_resnet.SpikingResNet(block, layers, num_classes=1000, zero_init_residual=False, groups=1, width_per_group=64, replace_stride_with_dilation=None, norm_layer=None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]

基类:Module

forward(x)[源代码]
training: bool
spikingjelly.activation_based.model.spiking_resnet.spiking_resnet18(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNet-18

返回类型:

torch.nn.Module

A spiking version of ResNet-18 model from “Deep Residual Learning for Image Recognition”

spikingjelly.activation_based.model.spiking_resnet.spiking_resnet34(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNet-34

返回类型:

torch.nn.Module

A spiking version of ResNet-34 model from “Deep Residual Learning for Image Recognition”

spikingjelly.activation_based.model.spiking_resnet.spiking_resnet50(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNet-50

返回类型:

torch.nn.Module

A spiking version of ResNet-50 model from “Deep Residual Learning for Image Recognition”

spikingjelly.activation_based.model.spiking_resnet.spiking_resnet101(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNet-101

返回类型:

torch.nn.Module

A spiking version of ResNet-101 model from “Deep Residual Learning for Image Recognition”

spikingjelly.activation_based.model.spiking_resnet.spiking_resnet152(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a single step neuron

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNet-152

返回类型:

torch.nn.Module

A spiking version of ResNet-152 model from “Deep Residual Learning for Image Recognition”

spikingjelly.activation_based.model.spiking_resnet.spiking_resnext50_32x4d(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a single step neuron

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNeXt-50 32x4d

返回类型:

torch.nn.Module

A spiking version of ResNeXt-50 32x4d model from “Aggregated Residual Transformation for Deep Neural Networks”

spikingjelly.activation_based.model.spiking_resnet.spiking_resnext101_32x8d(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a single step neuron

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking ResNeXt-101 32x8d

返回类型:

torch.nn.Module

A spiking version of ResNeXt-101 32x8d model from “Aggregated Residual Transformation for Deep Neural Networks”

spikingjelly.activation_based.model.spiking_resnet.spiking_wide_resnet50_2(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a single step neuron

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking Wide ResNet-50-2

返回类型:

torch.nn.Module

A spiking version of Wide ResNet-50-2 model from “Wide Residual Networks”

The model is the same as ResNet except for the bottleneck number of channels which is twice larger in every block. The number of channels in outer 1x1 convolutions is the same, e.g. last block in ResNet-50 has 2048-512-2048 channels, and in Wide ResNet-50-2 has 2048-1024-2048.

spikingjelly.activation_based.model.spiking_resnet.spiking_wide_resnet101_2(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a single step neuron

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking Wide ResNet-101-2

返回类型:

torch.nn.Module

A spiking version of Wide ResNet-101-2 model from “Wide Residual Networks”

The model is the same as ResNet except for the bottleneck number of channels which is twice larger in every block. The number of channels in outer 1x1 convolutions is the same, e.g. last block in ResNet-50 has 2048-512-2048 channels, and in Wide ResNet-50-2 has 2048-1024-2048.

spikingjelly.activation_based.model.spiking_vgg module

class spikingjelly.activation_based.model.spiking_vgg.SpikingVGG(cfg, batch_norm=False, norm_layer=None, num_classes=1000, init_weights=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]

基类:Module

forward(x)[源代码]
static make_layers(cfg, batch_norm=False, norm_layer=None, neuron: Optional[callable] = None, **kwargs)[源代码]
training: bool
spikingjelly.activation_based.model.spiking_vgg.spiking_vgg11(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking VGG-11

返回类型:

torch.nn.Module

A spiking version of VGG-11 model from “Very Deep Convolutional Networks for Large-Scale Image Recognition”

spikingjelly.activation_based.model.spiking_vgg.spiking_vgg11_bn(pretrained=False, progress=True, norm_layer: Optional[callable] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • norm_layer (callable) – a batch norm layer

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking VGG-11 with norm layer

返回类型:

torch.nn.Module

A spiking version of VGG-11-BN model from “Very Deep Convolutional Networks for Large-Scale Image Recognition”

spikingjelly.activation_based.model.spiking_vgg.spiking_vgg13(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking VGG-13

返回类型:

torch.nn.Module

A spiking version of VGG-13 model from “Very Deep Convolutional Networks for Large-Scale Image Recognition”

spikingjelly.activation_based.model.spiking_vgg.spiking_vgg13_bn(pretrained=False, progress=True, norm_layer: Optional[callable] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • norm_layer (callable) – a batch norm layer

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking VGG-11 with norm layer

返回类型:

torch.nn.Module

A spiking version of VGG-13-BN model from “Very Deep Convolutional Networks for Large-Scale Image Recognition”

spikingjelly.activation_based.model.spiking_vgg.spiking_vgg16(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking VGG-16

返回类型:

torch.nn.Module

A spiking version of VGG-16 model from “Very Deep Convolutional Networks for Large-Scale Image Recognition”

spikingjelly.activation_based.model.spiking_vgg.spiking_vgg16_bn(pretrained=False, progress=True, norm_layer: Optional[callable] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • norm_layer (callable) – a batch norm layer

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking VGG-16 with norm layer

返回类型:

torch.nn.Module

A spiking version of VGG-16-BN model from “Very Deep Convolutional Networks for Large-Scale Image Recognition”

spikingjelly.activation_based.model.spiking_vgg.spiking_vgg19(pretrained=False, progress=True, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking VGG-19

返回类型:

torch.nn.Module

A spiking version of VGG-19 model from “Very Deep Convolutional Networks for Large-Scale Image Recognition”

spikingjelly.activation_based.model.spiking_vgg.spiking_vgg19_bn(pretrained=False, progress=True, norm_layer: Optional[callable] = None, spiking_neuron: Optional[callable] = None, **kwargs)[源代码]
参数:
  • pretrained (bool) – If True, the SNN will load parameters from the ANN pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

  • norm_layer (callable) – a batch norm layer

  • spiking_neuron (callable) – a spiking neuron layer

  • kwargs (dict) – kwargs for spiking_neuron

返回:

Spiking VGG-19 with norm layer

返回类型:

torch.nn.Module

A spiking version of VGG-19-BN model from “Very Deep Convolutional Networks for Large-Scale Image Recognition”

spikingjelly.activation_based.model.train_classify module

spikingjelly.activation_based.model.train_classify.set_deterministic(_seed_: int = 2020, disable_uda=False)[源代码]
spikingjelly.activation_based.model.train_classify.seed_worker(worker_id)[源代码]
class spikingjelly.activation_based.model.train_classify.Trainer[源代码]

基类:object

cal_acc1_acc5(output, target)[源代码]
preprocess_train_sample(args, x: Tensor)[源代码]
preprocess_test_sample(args, x: Tensor)[源代码]
process_model_output(args, y: Tensor)[源代码]
train_one_epoch(model, criterion, optimizer, data_loader, device, epoch, args, model_ema=None, scaler=None)[源代码]
evaluate(args, model, criterion, data_loader, device, log_suffix='')[源代码]
load_data(args)[源代码]
load_CIFAR10(args)[源代码]
load_ImageNet(args)[源代码]
load_model(args, num_classes)[源代码]
get_tb_logdir_name(args)[源代码]
set_optimizer(args, parameters)[源代码]
set_lr_scheduler(args, optimizer)[源代码]
main(args)[源代码]
before_test_one_epoch(args, model, epoch)[源代码]
before_train_one_epoch(args, model, epoch)[源代码]
get_args_parser(add_help=True)[源代码]

spikingjelly.activation_based.model.train_imagenet module

Module contents