项目作者: HiroshiARAKI

项目描述 :
A tiny Spiking neural network library implemented by BindsNet.
高级语言: Python
项目地址: git://github.com/HiroshiARAKI/snnlibpy.git
创建时间: 2019-10-07T14:10:05Z
项目社区:https://github.com/HiroshiARAKI/snnlibpy

开源协议:

下载


WrappedBindsNET

update

これはBindsNETと呼ばれるPyTorchベースのSpiking Neural Networksフレームワークをさらに使いやすくしよう,
というコンセプトのもと作成中.
この小さなライブラリは,大体snnlib.pyに詰められているので,各種定数などはかなり弄りやすいかと思います.
もちろん,main.pyから直接クラス変数は変更できます.
完全に個人利用ですが,使いたい人がいればご自由にどうぞ
(結構頻繁に小さな(大したことない)アップデートをしています.)

作者の修士課程修了に伴い,大きなアップデートは今後おそらくありませんが,これを拡張して利用することは歓迎いたします.

I am making a tiny and user friendly library of Spiking Neural Networks with BindsNET.
All functions are packed to only snnlib.py, so you can use easily.
This library is used by private myself, but if you want to use it, feel free to use.

未完成につきバグがまだある可能性があります.(Maybe, there are bugs because this is incompletely.)

実行保証環境 (Environment)

以下の環境において問題なく実行可能なことを確認しています.

  • OS………MacOS 10.15 or Ubuntu 16.04 LTS
  • Python…..3.6. or 3.7. (, or later)
  • BindsNET…0.2.7 (not worked on < 0.2.7)
  • PyTorch….1.10
    (GPU: torch… 1.3.0+cu92, torchvision… 0.4.1+cu92)

Example

  • Sample code
    ```python
    from wbn import Spiking

if name == ‘main‘:

  1. # Build SNNs and decide the number of input neurons and the simulation time.
  2. snn = Spiking(input_l=784, obs_time=300, dt=0.5)
  3. snn.IMAGE_DIR += 'diehl/'
  4. # Add a layer and give the num of neurons and the neuron model.
  5. snn.add_layer(n=100,
  6. node=snn.DIEHL_COOK, # or snn.DIEHL_COOK
  7. w=snn.W_SIMPLE_RAND, # initialize weights
  8. rule=snn.SIMPLE_STDP, # learning rule
  9. nu=(1e-4, 1e-2), # learning rate
  10. )
  11. # Add an inhibitory layer
  12. snn.add_inhibit_layer(inh_w=-128)
  13. # Load dataset
  14. snn.load_MNIST()
  15. # Check your network architecture
  16. snn.print_model()
  17. # If you use a small network, your network computation by GPU may be more slowly than CPU.
  18. # So you can change directly whether using GPU or not as below.
  19. # snn.gpu = False
  20. # Gpu is available?? If available, make it use.
  21. snn.to_gpu()
  22. # Plot weight maps before training
  23. snn.plot(plt_type='wmps', prefix='0', f_shape=(10, 10))
  24. # Make my network run
  25. for i in range(3):
  26. snn.run()
  27. snn.plot(plt_type='wmps', prefix='{}'.format(i+1), f_shape=(10, 10)) # plot maps
  28. # Plot test accuracy transition
  29. snn.plot(plt_type='history', prefix='result')
  30. # Plot weight maps after training
  31. snn.plot(plt_type='wmps', prefix='result', f_shape=(10, 10))
  32. # Plot output spike trains after training
  33. snn.plot(plt_type='sp', range=10)
  34. print(snn.history)
  1. or very simply,
  2. ```python
  3. from wbn import DiehlCook_unsupervised_model # packed sample simulation code
  4. DiehlCook_unsupervised_model()

is ok (actually this function is my backup data, so it’s good for you to use this when you check whether it works properly).

  • Generated image samples

    • A weight map before training
      pre_training

    • A weight map after STDP training with 1,0000 MNIST data
      pre_training

BindsNET references

【docs】
Welcome to BindsNET’s documentation! — bindsnet 0.2.5 documentation

【Github】
Hananel-Hazan/bindsnet: Simulation of spiking neural networks (SNNs) using PyTorch.

【Paper】
BindsNET: A Machine Learning-Oriented Spiking Neural Networks Library in Python