
大脑是寻找灵感来开发更有效的神经网络的理想场所。现代深度学习的主要区别之一是,大脑在尖峰中编码信息而不是连续激活。 Snntorch是用于使用尖峰神经网络进行基于梯度的学习的Python软件包。它扩展了Pytorch的功能,利用其GPU加速张量计算并将其应用于尖峰神经元网络。预先设计的尖峰神经元模型无缝集成在Pytorch框架中,并且可以视为经常性激活单元。

如果您喜欢这个项目,请考虑主演此存储库,因为它是支持它的最简单和最佳方法。
如果您有问题,评论或正在寻找有关培训尖峰神经网络的建议,则可以在我们的Discord频道中打开问题,讨论或聊天。
Snntorch包含以下组件:
| 成分 | 描述 |
|---|---|
| Snntorch | 像Torch.nn这样的尖峰神经元库,与自动摩rad式深入整合 |
| snntorch.export | 通过NIR启用与其他SNN库的交叉兼容性 |
| snntorch。功能 | 关于峰值的常见算术操作,例如,损失,正则化等。 |
| snntorch.spikegen | 用于生成和数据转换的库 |
| snntorch.spikeplot | 使用matplotlib和赛璐oid的可视化工具用于基于尖峰的数据 |
| snntorch.surogate | 可选的替代梯度功能 |
| snntorch.utils | 数据集实用程序功能 |
Snntorch设计为直观地与Pytorch一起使用,好像每个尖峰神经元只是一系列层中的另一种激活。因此,它不可知到完全连接的层,卷积层,残留连接等。
目前,神经元模型由递归函数表示,这些功能消除了系统中所有神经元的膜电位痕迹的需求,以便计算梯度。 SNNTORCH的精益要求使小型和大型网络能够在需要的情况下在CPU上进行训练。只要将网络模型和张量加载到CUDA上,SNNTORCH以与Pytorch相同的方式利用GPU加速度。
如果您发现Snntorch在您的工作中有用,请引用以下来源:
Jason K. Eshraghian,Max Ward,Emre Neftci,Xinxin Wang,Gregor Lenz,Girish Dwivedi,Mohammed Bennamoun,Doo Seok Jeong和Wei D. IEEE的会议记录,111(9)2023年9月。
@article{eshraghian2021training,
title = {Training spiking neural networks using lessons from deep learning},
author = {Eshraghian, Jason K and Ward, Max and Neftci, Emre and Wang, Xinxin
and Lenz, Gregor and Dwivedi, Girish and Bennamoun, Mohammed and
Jeong, Doo Seok and Lu, Wei D},
journal = {Proceedings of the IEEE},
volume = {111},
number = {9},
pages = {1016--1054},
year = {2023}
}让我们知道您是否在任何有趣的工作,研究或博客中使用Snntorch,因为我们很想听听有关它的更多信息!通过[email protected]与您联系。
需要安装以下软件包以使用snntorch:
如果使用PIP命令安装SNNTORCH,则会自动安装它们。确保为系统安装正确的火炬,以启用CUDA兼容性。
运行以下安装:
$ python
$ pip install snntorch改用来源安装snntorch:
$ git克隆https://github.com/jeshraghian/snntorch $ cd snntorch $ python setup.py安装
使用Conda安装SNNTORCH:
$ conda install -c conda -forge snntorch
使用GraphCore的加速器安装以智能处理单元(IPU)构建:
$ pip安装snntorch-ipu
这里有完整的API。提供了示例,教程和COLAB笔记本。
您可以从Snntorch开始以下几种方法:
有关运行snntorch的快速示例,请参见以下片段,或测试Quickstart Notebook:
import torch , torch . nn as nn
import snntorch as snn
from snntorch import surrogate
from snntorch import utils
num_steps = 25 # number of time steps
batch_size = 1
beta = 0.5 # neuron decay rate
spike_grad = surrogate . fast_sigmoid () # surrogate gradient
net = nn . Sequential (
nn . Conv2d ( 1 , 8 , 5 ),
nn . MaxPool2d ( 2 ),
snn . Leaky ( beta = beta , init_hidden = True , spike_grad = spike_grad ),
nn . Conv2d ( 8 , 16 , 5 ),
nn . MaxPool2d ( 2 ),
snn . Leaky ( beta = beta , init_hidden = True , spike_grad = spike_grad ),
nn . Flatten (),
nn . Linear ( 16 * 4 * 4 , 10 ),
snn . Leaky ( beta = beta , init_hidden = True , spike_grad = spike_grad , output = True )
)
data_in = torch . rand ( num_steps , batch_size , 1 , 28 , 28 ) # random input data
spike_recording = [] # record spikes over time
utils . reset ( net ) # reset/initialize hidden states for all neurons
for step in range ( num_steps ): # loop over time
spike , state = net ( data_in [ step ]) # one time step of forward-pass
spike_recording . append ( spike ) # record spikes in list 如果您想学习培训尖峰神经网络的所有基础,从神经元模型到神经代码,再到反向传播,Snntorch教程系列是一个不错的起点。它由交互式笔记本电脑组成,并具有完整的解释,可以使您迅速发展。
| 教程 | 标题 | COLAB链接 |
|---|---|---|
| 教程1 | 用snntorch编码尖峰 | |
| 教程2 | 泄漏的整合和火神经元 | |
| 教程3 | 馈送尖峰神经网络 | |
| 教程4 | 第二阶峰值神经元模型(可选) | |
| 教程5 | 与Snntorch一起培训尖峰神经网络 | |
| 教程6 | 卷积SNN中的替代梯度下降 | |
| 教程7 | 具有补品 + snntorch的神经形态数据集 |
| 高级教程 | COLAB链接 |
|---|---|
| 人口编码 | |
| 回归:第一部分 - 使用LIF神经元的膜潜在学习 | |
| 回归:第二部分 - 基于回归的LIF神经元的分类 | |
| 加速IPU上的snntorch | - |
SNNTORCH已针对GraphCore的IPU加速器进行了优化。要安装基于IPU的SNNTORCH的构建:
$ pip安装snntorch-ipu
首次import snntorch时,将自动编译用于IPU兼容性的低级自定义操作。
更新Poplar SDK时,可能需要重新编译这些操作。这可以通过重新安装snntorch-ipu或使用.So扩展名中的基本目录中删除文件来完成。
snntorch.backprop模块,以及来自snntorch.functional功能和snntorch.surrogate几个功能,与ipus不相容,但可以使用pytorch opentives重新创建。
其他要求包括:
有关Poptorch和Poplar SDK的安装说明,请参阅GraphCore的文档。
可以在此处找到Snntorch IPU项目的主页。这里提供了培训SNN的教程。
如果您准备为Snntorch做出贡献,可以在此处找到这样做的说明。
SNNTORCH目前由UCSC神经形态计算组维护。它最初是由Jason K. Eshraghian在Lu Group(密歇根大学)中开发的。
Vincent Sun,Peng Zhou,Ridger Zhu,Alexander Henkes,Steven Abreu,Xinxin Wang,Sreyes Venkatesh,Gekkom和Emre Neftci做出了其他贡献。
SNNTORCH源代码按照MIT许可条款发布。 Snntorch的文档在创意共享归因共享下获得许可。