spikingjelly.clock_driven.examples package
Subpackages
Submodules
spikingjelly.clock_driven.examples.A2C module
spikingjelly.clock_driven.examples.DQN_state module
spikingjelly.clock_driven.examples.PPO module
spikingjelly.clock_driven.examples.Spiking_A2C module
spikingjelly.clock_driven.examples.Spiking_DQN_state module
- class spikingjelly.clock_driven.examples.Spiking_DQN_state.Transition(state, action, next_state, reward)
基类:
tuple
Create new instance of Transition(state, action, next_state, reward)
- property action
Alias for field number 1
- property next_state
Alias for field number 2
- property reward
Alias for field number 3
- property state
Alias for field number 0
- class spikingjelly.clock_driven.examples.Spiking_DQN_state.NonSpikingLIFNode(*args, **kwargs)[源代码]
基类:
LIFNode
- class spikingjelly.clock_driven.examples.Spiking_DQN_state.DQSN(input_size, hidden_size, output_size, T=16)[源代码]
基类:
Module
spikingjelly.clock_driven.examples.Spiking_PPO module
spikingjelly.clock_driven.examples.cifar10_r11_enabling_spikebased_backpropagation module
代码作者: Yanqi Chen <chyq@pku.edu.cn>
A reproduction of the paper Enabling Spike-Based Backpropagation for Training Deep Neural Network Architectures.
This code reproduces a novel gradient-based training method of SNN. We to some extent refer to the network structure and some other detailed implementation in the authors’ implementation. Since the training method and neuron models are slightly different from which in this framework, we rewrite them in a compatible style.
Assuming you have at least 1 Nvidia GPU.
- class spikingjelly.clock_driven.examples.cifar10_r11_enabling_spikebased_backpropagation.relu[源代码]
基类:
Function
- class spikingjelly.clock_driven.examples.cifar10_r11_enabling_spikebased_backpropagation.BaseNode(v_threshold=1.0, v_reset=0.0, surrogate_function=<built-in method apply of FunctionMeta object>, monitor=False)[源代码]
基类:
Module
- class spikingjelly.clock_driven.examples.cifar10_r11_enabling_spikebased_backpropagation.LIFNode(tau=100.0, v_threshold=1.0, v_reset=0.0, surrogate_function=<built-in method apply of FunctionMeta object>, fire=True)[源代码]
基类:
BaseNode
- class spikingjelly.clock_driven.examples.cifar10_r11_enabling_spikebased_backpropagation.IFNode(v_threshold=0.75, v_reset=0.0, surrogate_function=<built-in method apply of FunctionMeta object>)[源代码]
基类:
BaseNode
spikingjelly.clock_driven.examples.classify_dvsg module
- spikingjelly.clock_driven.examples.classify_dvsg.main()[源代码]
-
用于分类DVS128 Gesture数据集的代码样例。网络结构来自于 Incorporating Learnable Membrane Time Constant to Enhance Learning of Spiking Neural Networks。
usage: classify_dvsg.py [-h] [-T T] [-device DEVICE] [-b B] [-epochs N] [-j N] [-channels CHANNELS] [-data_dir DATA_DIR] [-out_dir OUT_DIR] [-resume RESUME] [-amp] [-cupy] [-opt OPT] [-lr LR] [-momentum MOMENTUM] [-lr_scheduler LR_SCHEDULER] [-step_size STEP_SIZE] [-gamma GAMMA] [-T_max T_MAX] Classify DVS128 Gesture optional arguments: -h, --help show this help message and exit -T T simulating time-steps -device DEVICE device -b B batch size -epochs N number of total epochs to run -j N number of data loading workers (default: 4) -channels CHANNELS channels of Conv2d in SNN -data_dir DATA_DIR root dir of DVS128 Gesture dataset -out_dir OUT_DIR root dir for saving logs and checkpoint -resume RESUME resume from the checkpoint path -amp automatic mixed precision training -cupy use CUDA neuron and multi-step forward mode -opt OPT use which optimizer. SDG or Adam -lr LR learning rate -momentum MOMENTUM momentum for SGD -lr_scheduler LR_SCHEDULER use which schedule. StepLR or CosALR -step_size STEP_SIZE step_size for StepLR -gamma GAMMA gamma for StepLR -T_max T_MAX T_max for CosineAnnealingLR
运行示例:
python -m spikingjelly.clock_driven.examples.classify_dvsg -data_dir /userhome/datasets/DVS128Gesture -out_dir ./logs -amp -opt Adam -device cuda:0 -lr_scheduler CosALR -T_max 64 -cupy -epochs 1024
阅读教程 分类DVS128 Gesture 以获得更多信息。
The code example for classifying the DVS128 Gesture dataset. The network structure is from Incorporating Learnable Membrane Time Constant to Enhance Learning of Spiking Neural Networks.
usage: classify_dvsg.py [-h] [-T T] [-device DEVICE] [-b B] [-epochs N] [-j N] [-channels CHANNELS] [-data_dir DATA_DIR] [-out_dir OUT_DIR] [-resume RESUME] [-amp] [-cupy] [-opt OPT] [-lr LR] [-momentum MOMENTUM] [-lr_scheduler LR_SCHEDULER] [-step_size STEP_SIZE] [-gamma GAMMA] [-T_max T_MAX] Classify DVS128 Gesture optional arguments: -h, --help show this help message and exit -T T simulating time-steps -device DEVICE device -b B batch size -epochs N number of total epochs to run -j N number of data loading workers (default: 4) -channels CHANNELS channels of Conv2d in SNN -data_dir DATA_DIR root dir of DVS128 Gesture dataset -out_dir OUT_DIR root dir for saving logs and checkpoint -resume RESUME resume from the checkpoint path -amp automatic mixed precision training -cupy use CUDA neuron and multi-step forward mode -opt OPT use which optimizer. SDG or Adam -lr LR learning rate -momentum MOMENTUM momentum for SGD -lr_scheduler LR_SCHEDULER use which schedule. StepLR or CosALR -step_size STEP_SIZE step_size for StepLR -gamma GAMMA gamma for StepLR -T_max T_MAX T_max for CosineAnnealingLR
Running Example:
python -m spikingjelly.clock_driven.examples.classify_dvsg -data_dir /userhome/datasets/DVS128Gesture -out_dir ./logs -amp -opt Adam -device cuda:0 -lr_scheduler CosALR -T_max 64 -cupy -epochs 1024
See the tutorial Classify DVS128 Gesture for more details.
spikingjelly.clock_driven.examples.conv_fashion_mnist module
- spikingjelly.clock_driven.examples.conv_fashion_mnist.main()[源代码]
-
Classify Fashion-MNIST
- optional arguments:
- -h, --help
show this help message and exit
- -T T
simulating time-steps
-device DEVICE device -b B batch size -epochs N number of total epochs to run -j N number of data loading workers (default: 4) -data_dir DATA_DIR root dir of Fashion-MNIST dataset -out_dir OUT_DIR root dir for saving logs and checkpoint -resume RESUME resume from the checkpoint path -amp automatic mixed precision training -cupy use cupy neuron and multi-step forward mode -opt OPT use which optimizer. SDG or Adam -lr LR learning rate -momentum MOMENTUM momentum for SGD -lr_scheduler LR_SCHEDULER
use which schedule. StepLR or CosALR
-step_size STEP_SIZE step_size for StepLR -gamma GAMMA gamma for StepLR -T_max T_MAX T_max for CosineAnnealingLR
使用卷积-全连接的网络结构,进行Fashion MNIST识别。这个函数会初始化网络进行训练,并显示训练过程中在测试集的正确率。会将训练过 程中测试集正确率最高的网络保存在
tensorboard
日志文件的同级目录下。这个目录的位置,是在运行main()
函数时由用户输入的。训练100个epoch,训练batch和测试集上的正确率如下:
The network with Conv-FC structure for classifying Fashion MNIST. This function initials the network, starts training and shows accuracy on test dataset. The net with the max accuracy on test dataset will be saved in the root directory for saving
tensorboard
logs, which is inputted by user when running themain()
function.After 100 epochs, the accuracy on train batch and test dataset is as followed:
spikingjelly.clock_driven.examples.conv_fashion_mnist_cuda_lbl module
spikingjelly.clock_driven.examples.dqn_cart_pole module
- class spikingjelly.clock_driven.examples.dqn_cart_pole.Transition(state, action, next_state, reward)
基类:
tuple
Create new instance of Transition(state, action, next_state, reward)
- property action
Alias for field number 1
- property next_state
Alias for field number 2
- property reward
Alias for field number 3
- property state
Alias for field number 0
- class spikingjelly.clock_driven.examples.dqn_cart_pole.NonSpikingLIFNode(*args, **kwargs)[源代码]
基类:
LIFNode