snntorch

使用Python進行脈衝神經網路的深度學習與線上學習

snntorch 是什麼?

使用Python進行脈衝神經網路的深度學習與線上學習    

snntorch 概覽

這是什麼

snnTorch 是一個用於在脈衝神經網路(SNN)上進行基於梯度學習的 Python 套件。它擴展了 PyTorch 的功能,將預先設計的脈衝神經元模型整合進來,這些模型可以被視為遞迴激活單元。該套件利用 PyTorch 的 GPU 加速張量計算,並將其應用於脈衝神經元網路。snnTorch 設計為可直觀地與 PyTorch 一起使用,就像每個脈衝神經元只是層序列中的另一個激活函數一樣。它與全連接層、卷積層、殘差連接等無關。神經元模型由遞迴函數表示,這消除了為計算梯度而儲存系統中所有神經元膜電位軌跡的需求。這使得小型和大型網路在需要時可以在 CPU 上有效訓練,並在張量載入 CUDA 時在 GPU 上訓練。

主要功能

  • 脈衝神經元庫(snntorch)與自動梯度深度整合,類似於 torch.nn。
  • 透過 snntorch.export_nir 和 snntorch.import_nir 使用 NIR(神經交換表示)格式進行匯出和匯入。
  • 脈衝的函數操作(snntorch.functional),包括損失函數和正則化。
  • 脈衝生成和資料轉換(snntorch.spikegen)。
  • 使用 matplotlib 和 celluloid 的脈衝資料視覺化工具(snntorch.spikeplot)。
  • 可選的代理梯度函數(snntorch.surrogate)。
  • 脈衝感知權重初始化函數(snntorch.weight_init)和資料集工具函數(snntorch.utils)。

使用情境

snnTorch 用於使用基於梯度的學習方法訓練脈衝神經網路(SNN)。它適用於神經形態計算的研究和開發,利用大腦基於脈衝的資訊編碼來開發更高效的神經網路。該套件可應用於影像分類、時間模式識別以及任何受益於事件驅動計算的問題。它也用於探索使用脈衝神經元進行線上學習和深度學習。

快速開始

透過 pip 安裝 snnTorch:bashpip install snntorch從原始碼安裝:bashgit clone https://github.com/jeshraghian/snnTorchcd snntorchpython setup.py install使用 conda 安裝:bashconda install -c conda-forge snntorch快速範例(需要 PyTorch):pythonimport torch, torch.nn as nnimport snntorch as snnfrom snntorch import surrogatefrom snntorch import utilsnum_steps = 25batch_size = 1beta = 0.5spike_grad = surrogate.fast_sigmoid()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)spike_recording = []utils.reset(net)for step in range(num_steps): spike, state = net(data_in[step]) spike_recording.append(spike)

授權與價格

授權為 MIT。價格類型為開源。

內容整理自該專案公開的 README 與儲存庫資訊。

將此徽章加入你的 README

Featured on YunoDB 徽章樣式與說明

你是這個專案的維護者嗎?展示它已收錄於 YunoDB。

Markdown[![Featured on YunoDB](https://yunodb.com/badge/jeshraghiansnntorch.svg)](https://yunodb.com/tools/jeshraghiansnntorch?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/jeshraghiansnntorch?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/jeshraghiansnntorch.svg" alt="Featured on YunoDB" height="20"></a>