ภาษาอังกฤษ | 中文 (จีน)

SpikingJelly เป็นกรอบการเรียนรู้ที่ลึกซึ้งโอเพนซอร์ซสำหรับการ Spiking Neural Network (SNN) ตาม Pytorch
เอกสารของ SpikingJelly เขียนขึ้นทั้งภาษาอังกฤษและภาษาจีน: https://spikingjelly.readthedocs.io
โปรดทราบว่า SpikingJelly ขึ้นอยู่กับ Pytorch โปรดตรวจสอบให้แน่ใจว่าคุณได้ติดตั้ง pytorch ก่อนที่จะติดตั้ง SpikingJelly
หมายเหตุเวอร์ชัน
หมายเลขเวอร์ชันคี่คือเวอร์ชันที่กำลังพัฒนาอัปเดตด้วยที่เก็บ GitHub/OpenI หมายเลขเวอร์ชันที่สม่ำเสมอคือเวอร์ชันที่เสถียรและสามารถใช้ได้ที่ PYPI
เอกสารเริ่มต้นสำหรับเวอร์ชันการพัฒนาล่าสุด หากคุณใช้เวอร์ชันที่เสถียรอย่าลืมเปลี่ยนไปใช้เอกสารในเวอร์ชันที่เกี่ยวข้อง
จากเวอร์ชัน 0.0.0.0.14 โมดูลรวมถึง clock_driven และ event_driven จะถูกเปลี่ยนชื่อ โปรดดูที่การสอนการโยกย้ายจากรุ่นเก่า
หากคุณใช้ SpikingJelly เวอร์ชันเก่าคุณอาจพบกับข้อบกพร่องที่ร้ายแรง อ้างถึงประวัติข้อบกพร่องพร้อมการเผยแพร่สำหรับรายละเอียดเพิ่มเติม
เอกสารสำหรับเวอร์ชันต่าง ๆ :
ติดตั้งเวอร์ชันที่เสถียรล่าสุดจาก PYPI :
pip install spikingjellyติดตั้งเวอร์ชันการพัฒนาล่าสุดจากซอร์สโค้ด :
จาก GitHub:
git clone https://github.com/fangwei123456/spikingjelly.git
cd spikingjelly
python setup.py installจาก Openi:
git clone https://openi.pcl.ac.cn/OpenI/spikingjelly.git
cd spikingjelly
python setup.py installSpikingJelly เป็นมิตรกับผู้ใช้ การสร้าง snn ด้วย spikingjelly นั้นง่ายเหมือนการสร้างแอนใน Pytorch:
nn . Sequential (
layer . Flatten (),
layer . Linear ( 28 * 28 , 10 , bias = False ),
neuron . LIFNode ( tau = tau , surrogate_function = surrogate . ATan ())
)เครือข่ายที่เรียบง่ายนี้ด้วยเครื่องเข้ารหัสปัวซองสามารถบรรลุความแม่นยำ 92% ในชุดข้อมูลการทดสอบ MNIST อ่านอ้างอิงถึงการสอนสำหรับรายละเอียดเพิ่มเติม นอกจากนี้คุณยังสามารถเรียกใช้รหัสนี้ในเทอร์มินัล Python สำหรับการฝึกอบรมในการจำแนก MNIST:
python - m spikingjelly . activation_based . examples . lif_fc_mnist - tau 2.0 - T 100 - device cuda : 0 - b 64 - epochs 100 - data - dir < PATH to MNIST > - amp - opt adam - lr 1e-3 - j 8 SpikingJelly ใช้อินเทอร์เฟซการแปลง ANN-SNN ที่ค่อนข้างทั่วไป ผู้ใช้สามารถตระหนักถึงการแปลงผ่าน Pytorch ยิ่งไปกว่านั้นผู้ใช้สามารถปรับแต่งโหมดการแปลง
class ANN ( nn . Module ):
def __init__ ( self ):
super (). __init__ ()
self . network = nn . Sequential (
nn . Conv2d ( 1 , 32 , 3 , 1 ),
nn . BatchNorm2d ( 32 , eps = 1e-3 ),
nn . ReLU (),
nn . AvgPool2d ( 2 , 2 ),
nn . Conv2d ( 32 , 32 , 3 , 1 ),
nn . BatchNorm2d ( 32 , eps = 1e-3 ),
nn . ReLU (),
nn . AvgPool2d ( 2 , 2 ),
nn . Conv2d ( 32 , 32 , 3 , 1 ),
nn . BatchNorm2d ( 32 , eps = 1e-3 ),
nn . ReLU (),
nn . AvgPool2d ( 2 , 2 ),
nn . Flatten (),
nn . Linear ( 32 , 10 )
)
def forward ( self , x ):
x = self . network ( x )
return xเครือข่ายง่าย ๆ ที่มีการเข้ารหัสแบบอะนาล็อกสามารถบรรลุความแม่นยำ 98.44% หลังจากการแปลงในชุดข้อมูลการทดสอบ MNIST อ่านบทช่วยสอนสำหรับรายละเอียดเพิ่มเติม นอกจากนี้คุณยังสามารถเรียกใช้รหัสนี้ในเทอร์มินัล Python สำหรับการฝึกอบรมในการจำแนก MNIST โดยใช้โมเดลที่แปลงแล้ว:
> >> import spikingjelly . activation_based . ann2snn . examples . cnn_mnist as cnn_mnist
> >> cnn_mnist . main () SpikingJelly ให้สองแบ็กเอนด์สำหรับเซลล์ประสาทหลายขั้นตอน คุณสามารถใช้แบ็กเอนด์ torch ที่ใช้งานง่ายสำหรับการเข้ารหัสและการดีบักได้อย่างง่ายดายและใช้แบ็กเอนด์ cupy เพื่อความเร็วในการฝึกอบรมที่เร็วขึ้น
รูปต่อไปนี้เปรียบเทียบเวลาดำเนินการของสองแบ็กเอนด์ของเซลล์ประสาท LIF หลายขั้นตอน ( float32 ):

float16 มีให้โดยแบ็กเอนด์ cupy และสามารถใช้ในการฝึกอบรมความแม่นยำแบบผสมอัตโนมัติ
หากต้องการใช้แบ็กเอนด์ cupy โปรดติดตั้ง Cupy โปรดทราบว่าแบ็กเอนด์ cupy รองรับ GPU เท่านั้นในขณะที่แบ็กเอน torch คบเพลิงรองรับทั้ง CPU และ GPU
ง่ายเหมือนการใช้ pytorch
> >> net = nn . Sequential ( layer . Flatten (), layer . Linear ( 28 * 28 , 10 , bias = False ), neuron . LIFNode ( tau = tau ))
> >> net = net . to ( device ) # Can be CPU or CUDA devices SpikingJelly รวมชุดข้อมูล neuromorphic ต่อไปนี้:
| ชุดข้อมูล | แหล่งที่มา |
|---|---|
| ASL-DVS | การจำแนกประเภทวัตถุที่ใช้กราฟสำหรับการตรวจจับการมองเห็น neuromorphic |
| CIFAR10-DVS | CIFAR10-DVS: ชุดข้อมูลสตรีมเหตุการณ์สำหรับการจำแนกวัตถุ |
| DVS128 ท่าทาง | ระบบการจดจำท่าทางที่ใช้งานได้อย่างเต็มที่ |
| es-imagenet | ES-IMAGENET: ชุดข้อมูลการจำแนกประเภทเหตุการณ์หนึ่งล้านรายการสำหรับเครือข่ายประสาท |
| Hardvs | Hardvs: ทบทวนการรับรู้กิจกรรมของมนุษย์ด้วยเซ็นเซอร์การมองเห็นแบบไดนามิก |
| N-Caltech101 | การแปลงชุดข้อมูลภาพคงที่เป็นชุดข้อมูล neuromorphic spiking โดยใช้ saccades |
| n-mnist | การแปลงชุดข้อมูลภาพคงที่เป็นชุดข้อมูล neuromorphic spiking โดยใช้ saccades |
| ท่าทางนาวี | การรับรู้ท่าทางตามเหตุการณ์ด้วยการปราบปรามพื้นหลังแบบไดนามิกโดยใช้ความสามารถในการคำนวณสมาร์ทโฟน |
| Spiking Heidelberg Digits (SHD) | ชุดข้อมูล heidelberg spiking สำหรับการประเมินอย่างเป็นระบบของเครือข่ายประสาท spiking |
| ดีวีดี | คุณสมบัติเชิงพื้นที่หลายตัวที่รับรู้เครือข่ายสำหรับการอ่านริมฝีปากตามเหตุการณ์ |
ผู้ใช้สามารถใช้ทั้งข้อมูลเหตุการณ์ต้นกำเนิดและข้อมูลเฟรมที่รวมโดย SpikingJelly:
import torch
from torch . utils . data import DataLoader
from spikingjelly . datasets import pad_sequence_collate , padded_sequence_mask
from spikingjelly . datasets . dvs128_gesture import DVS128Gesture
# Set the root directory for the dataset
root_dir = 'D:/datasets/DVS128Gesture'
# Load event dataset
event_set = DVS128Gesture ( root_dir , train = True , data_type = 'event' )
event , label = event_set [ 0 ]
# Print the keys and their corresponding values in the event data
for k in event . keys ():
print ( k , event [ k ])
# t [80048267 80048277 80048278 ... 85092406 85092538 85092700]
# x [49 55 55 ... 60 85 45]
# y [82 92 92 ... 96 86 90]
# p [1 0 0 ... 1 0 0]
# label 0
# Load a dataset with fixed frame numbers
fixed_frames_number_set = DVS128Gesture ( root_dir , train = True , data_type = 'frame' , frames_number = 20 , split_by = 'number' )
# Randomly select two frames and print their shapes
rand_index = torch . randint ( low = 0 , high = fixed_frames_number_set . __len__ (), size = [ 2 ])
for i in rand_index :
frame , label = fixed_frames_number_set [ i ]
print ( f'frame[ { i } ].shape=[T, C, H, W]= { frame . shape } ' )
# frame[308].shape=[T, C, H, W]=(20, 2, 128, 128)
# frame[453].shape=[T, C, H, W]=(20, 2, 128, 128)
# Load a dataset with a fixed duration and print the shapes of the first 5 samples
fixed_duration_frame_set = DVS128Gesture ( root_dir , data_type = 'frame' , duration = 1000000 , train = True )
for i in range ( 5 ):
x , y = fixed_duration_frame_set [ i ]
print ( f'x[ { i } ].shape=[T, C, H, W]= { x . shape } ' )
# x[0].shape=[T, C, H, W]=(6, 2, 128, 128)
# x[1].shape=[T, C, H, W]=(6, 2, 128, 128)
# x[2].shape=[T, C, H, W]=(5, 2, 128, 128)
# x[3].shape=[T, C, H, W]=(5, 2, 128, 128)
# x[4].shape=[T, C, H, W]=(7, 2, 128, 128)
# Create a data loader for the fixed duration frame dataset and print the shapes and sequence lengths
train_data_loader = DataLoader ( fixed_duration_frame_set , collate_fn = pad_sequence_collate , batch_size = 5 )
for x , y , x_len in train_data_loader :
print ( f'x.shape=[N, T, C, H, W]= { tuple ( x . shape ) } ' )
print ( f'x_len= { x_len } ' )
mask = padded_sequence_mask ( x_len ) # mask.shape = [T, N]
print ( f'mask= n { mask . t (). int () } ' )
break
# x.shape=[N, T, C, H, W]=(5, 7, 2, 128, 128)
# x_len=tensor([6, 6, 5, 5, 7])
# mask=
# tensor([[1, 1, 1, 1, 1, 1, 0],
# [1, 1, 1, 1, 1, 1, 0],
# [1, 1, 1, 1, 1, 0, 0],
# [1, 1, 1, 1, 1, 0, 0],
# [1, 1, 1, 1, 1, 1, 1]], dtype=torch.int32)ชุดข้อมูลเพิ่มเติมจะรวมอยู่ในอนาคต
หากลิงค์ดาวน์โหลดของชุดข้อมูลบางชุดไม่สามารถใช้ได้สำหรับผู้ใช้บางคนผู้ใช้สามารถดาวน์โหลดได้จาก Openi Mirror:
https://openi.pcl.ac.cn/openi/spikingjelly/datasets?type=0
ชุดข้อมูลทั้งหมดที่บันทึกไว้ใน Mirror Openi นั้นอนุญาตโดยใบอนุญาตหรือข้อตกลงของผู้เขียน
SpikingJelly ให้บทเรียนที่ซับซ้อน นี่คือบทเรียนบางส่วน:
| รูป | การสอน |
|---|---|
![]() | ความคิดพื้นฐาน |
![]() | เซลล์ประสาท |
![]() | เลเยอร์ที่เชื่อมต่ออย่างสมบูรณ์ SNN เพื่อจำแนก MNIST |
![]() | snn convolutional เพื่อจำแนก fmnist |
![]() | Ann2snn |
![]() | การประมวลผลชุดข้อมูล Neuromorphic |
![]() | จำแนกท่าทาง DVS |
![]() | การเชื่อมต่อที่เกิดขึ้นซ้ำและ synapse stateful |
![]() | การเรียนรู้ STDP |
![]() | การเรียนรู้เสริมแรง |
บทช่วยสอนอื่น ๆ ที่ไม่ได้อยู่ในรายการที่นี่ยังมีอยู่ที่เอกสาร https://spikingjelly.readthedocs.io
สิ่งพิมพ์ที่ใช้ SpikingJelly ถูกบันทึกไว้ในสิ่งพิมพ์ หากคุณใช้ spikingjelly ในกระดาษของคุณคุณสามารถเพิ่มลงในตารางนี้โดยคำขอดึง
หากคุณใช้ SpikingJelly ในงานของคุณโปรดอ้างอิงดังนี้:
@article{
doi:10.1126/sciadv.adi1480,
author = {Wei Fang and Yanqi Chen and Jianhao Ding and Zhaofei Yu and Timothée Masquelier and Ding Chen and Liwei Huang and Huihui Zhou and Guoqi Li and Yonghong Tian },
title = {SpikingJelly: An open-source machine learning infrastructure platform for spike-based intelligence},
journal = {Science Advances},
volume = {9},
number = {40},
pages = {eadi1480},
year = {2023},
doi = {10.1126/sciadv.adi1480},
URL = {https://www.science.org/doi/abs/10.1126/sciadv.adi1480},
eprint = {https://www.science.org/doi/pdf/10.1126/sciadv.adi1480},
abstract = {Spiking neural networks (SNNs) aim to realize brain-inspired intelligence on neuromorphic chips with high energy efficiency by introducing neural dynamics and spike properties. As the emerging spiking deep learning paradigm attracts increasing interest, traditional programming frameworks cannot meet the demands of automatic differentiation, parallel computation acceleration, and high integration of processing neuromorphic datasets and deployment. In this work, we present the SpikingJelly framework to address the aforementioned dilemma. We contribute a full-stack toolkit for preprocessing neuromorphic datasets, building deep SNNs, optimizing their parameters, and deploying SNNs on neuromorphic chips. Compared to existing methods, the training of deep SNNs can be accelerated 11×, and the superior extensibility and flexibility of SpikingJelly enable users to accelerate custom models at low costs through multilevel inheritance and semiautomatic code generation. SpikingJelly paves the way for synthesizing truly energy-efficient SNN-based machine intelligence systems, which will enrich the ecology of neuromorphic computing. Motivation and introduction of the software framework SpikingJelly for spiking deep learning.}}
คุณสามารถอ่านปัญหาและได้รับปัญหาในการแก้ไขและแผนการพัฒนาล่าสุด เรายินดีต้อนรับผู้ใช้ทุกคนที่จะเข้าร่วมการอภิปรายของแผนการพัฒนาแก้ปัญหาและส่งคำขอดึง
เอกสาร API ทั้งหมดไม่ได้เขียนทั้งภาษาอังกฤษและภาษาจีน เรายินดีต้อนรับผู้ใช้ให้ทำการแปลให้เสร็จสมบูรณ์ (จากภาษาอังกฤษเป็นภาษาจีนหรือจากภาษาจีนเป็นภาษาอังกฤษ)
กลุ่มการเรียนรู้มัลติมีเดียสถาบันสื่อดิจิทัล (NELVT) มหาวิทยาลัยปักกิ่งและห้องปฏิบัติการ Peng Cheng เป็นนักพัฒนาหลักของ Spikingjelly


รายชื่อนักพัฒนาสามารถพบได้ที่นี่