
大腦是尋找靈感來開發更有效的神經網絡的理想場所。現代深度學習的主要區別之一是,大腦在尖峰中編碼信息而不是連續激活。 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的文檔在創意共享歸因共享下獲得許可。