Git Product home page Git Product logo

vikram-mm / spiking-neural-network---theano-framework Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 3.0 63.79 MB

Spiking neural networks are biologically plausible CNNs which learn through a temporally dependent learning method known as Spike Time Dependant Plasticity (STDP)- an alternate to gradient descent. This repository contains layers built on top of Lasagne layers for spiking neural networks. This is the first implementation of spiking neural networks in any tensor based framework to the best of my knowledge. The various layers can be found in snn.py for dense layer and snn_conv.py for other layers. These layers are to be processed for each time step which is done using the Theano scan as a quick hack - in the snn class. The results can be found the ppt. Further details on how to use the code will be put up after later.

Python 96.55% Shell 0.14% Cuda 3.31%
spiking-neural-networks spike-time-dependent-plasticity stdp snn spike lasagne-layers tensor

spiking-neural-network---theano-framework's Introduction

Spiking-Neural-Network---Theano-Framework

Spiking neural networks are biologically plausible CNNs which learn through a temporally dependent learning method known as Spike Time Dependant Plasticity (STDP)- an alternate to gradient descent. This repository contains layers built on top of Lasagne layers for spiking neural networks. This is the first implementation of spiking neural networks in any tensor based framework to the best of my knowledge. The various layers can be found in snn.py for dense layer and snn_conv.py for other layers. These layers are to be processed for each time step which is done using the Theano scan as a quick hack - in the snn class. The results can be found the ppt. Further details on how to use the code will be put up after later.

spiking-neural-network---theano-framework's People

Contributors

vikram-mm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

spiking-neural-network---theano-framework's Issues

downsample error

i am trying to run your repo but found the following error . i am using the latest version of theano.

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-fdca8eb787d9> in <module>()
      9 import datetime
     10 import cv2
---> 11 import lasagne
     12 import matplotlib
     13 matplotlib.use('Agg')

~\Anaconda34\lib\site-packages\lasagne\__init__.py in <module>()
     17 from . import nonlinearities
     18 from . import init
---> 19 from . import layers
     20 from . import objectives
     21 from . import random

~\Anaconda34\lib\site-packages\lasagne\layers\__init__.py in <module>()
      5 from .noise import *
      6 from .conv import *
----> 7 from .pool import *
      8 from .shape import *
      9 from .merge import *

~\Anaconda34\lib\site-packages\lasagne\layers\pool.py in <module>()
      4 from ..utils import as_tuple
      5 
----> 6 from theano.tensor.signal import downsample
      7 
      8 

ImportError: cannot import name 'downsample'

ImportError: Cuda not found. Cannot unpickle CudaNdarray

i am trying to run your repo on my system but got the following error. i googled a lot to get rid of this but failed .i have intell(R) hd 4000 gpu. how can i run this piece of code on cpu instead of gpu need your suggestion how can i remove this errors

ImportError                               Traceback (most recent call last)
<ipython-input-11-ba73284be362> in <module>()
    537 if __name__ == '__main__':
    538     #train_snn_main()
--> 539     train_count_main()

<ipython-input-11-ba73284be362> in train_count_main()
    210     print ('loading snn')
    211     f = open(os.path.join(path, 'snn_autonet' + '.save'), 'rb')
--> 212     snn_loaded_object=cPickle.load(f)
    213     f.close()
    214     print('Done')

C:\ProgramData\Anaconda5\envs\py27\lib\site-packages\theano\sandbox\cuda\type.pyc in CudaNdarray_unpickler(npa)
    600         return cuda.CudaNdarray(npa)
    601     else:
--> 602         raise ImportError("Cuda not found. Cannot unpickle CudaNdarray")
    603 
    604 copyreg.constructor(CudaNdarray_unpickler)

ImportError: Cuda not found. Cannot unpickle CudaNdarray

some errors in runing stdp.py

Hello,
I am so sorry to bother you, but I really need your help. I am interested in your open source code about the software implementation of SNN very much and I want to reproduce the similar work. However, some errors appears when I run stdp.py in SNN_DEEP_NETWORKS\MNIST\ . I rewrite nothing about the code. I doubted that there may be something wrong about deps or envs. Here are the error prompt:

**`In file included from /home/siam7tong/anaconda3/envs/ten-gpu/include/python2.7/Python.h:8:0,
from mod.cu:1:
/home/siam7tong/anaconda3/envs/ten-gpu/include/python2.7/pyconfig.h:1190:0: warning: "_POSIX_C_SOURCE" redefined
#define _POSIX_C_SOURCE 200112L
^
In file included from /usr/local/cuda/bin/..//include/host_config.h:173:0,
from /usr/local/cuda/bin/..//include/cuda_runtime.h:78,
from :0:
/usr/include/features.h:228:0: note: this is the location of the previous definition

define _POSIX_C_SOURCE 200809L

^
In file included from /home/siam7tong/anaconda3/envs/ten-gpu/include/python2.7/Python.h:8:0,
from mod.cu:1:
/home/siam7tong/anaconda3/envs/ten-gpu/include/python2.7/pyconfig.h:1212:0: warning: "_XOPEN_SOURCE" redefined
#define _XOPEN_SOURCE 600
^
In file included from /usr/local/cuda/bin/..//include/host_config.h:173:0,
from /usr/local/cuda/bin/..//include/cuda_runtime.h:78,
from :0:
/usr/include/features.h:169:0: note: this is the location of the previous definition

define _XOPEN_SOURCE 700

^
mod.cu(461): error: identifier "argument" is undefined
mod.cu(462): error: expected a ";"
mod.cu(475): warning: parsing restarts here after previous syntax error
mod.cu(478): error: identifier "threads" is undefined
3 errors detected in the compilation of "/tmp/tmpxft_00001156_00000000-9_mod.cpp1.ii".
and the follows:Exception: ('nvcc return status', 2, 'for cmd', 'nvcc -shared -O3 -use_fast_math -arch=sm_50 -m64 -Xcompiler -fno-math-errno,-Wno-unused-label,-Wno-unused-variable,-Wno-write-strings,-D_FORCE_INLINES,-DCUDA_NDARRAY_CUH=c72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,-fPIC,-fvisibility=hidden -Xlinker -rpath,/home/siam7tong/.theano/compiledir_Linux-4.10--generic-x86_64-with-debian-stretch-sid-x86_64-2.7.13-64/cuda_ndarray -I/home/siam7tong/.theano/compiledir_Linux-4.10--generic-x86_64-with-debian-stretch-sid-x86_64-2.7.13-64/cuda_ndarray -I/usr/local/cuda #\xe8\xbf\x99\xe9\x87\x8c\xe4\xb8\x8d\xe8\x83\xbd\xe5\x8a\xa0/bin/include -I/home/siam7tong/anaconda3/envs/ten-gpu/lib/python2.7/site-packages/numpy/core/include -I/home/siam7tong/anaconda3/envs/ten-gpu/include/python2.7 -I/home/siam7tong/anaconda3/envs/ten-gpu/lib/python2.7/site-packages/theano/gof -I/home/siam7tong/anaconda3/envs/ten-gpu/lib/python2.7/site-packages/theano/sandbox/cuda -L/home/siam7tong/.theano/compiledir_Linux-4.10--generic-x86_64-with-debian-stretch-sid-x86_64-2.7.13-64/cuda_ndarray -L/home/siam7tong/anaconda3/envs/ten-gpu/lib -o /home/siam7tong/.theano/compiledir_Linux-4.10--generic-x86_64-with-debian-stretch-sid-x86_64-2.7.13-64/tmpwt0mAw/9b3abe76f03ac070241bb425805ecd23.so mod.cu -lcudart -lcublas -lcuda_ndarray -lpython2.7', '[<main.stdpOp object at 0x7fbaf8ed47d0>(<CudaNdarrayType(float32, 4D)>, <CudaNdarrayType(float32, 4D)>, <CudaNdarrayType(float32, 4D)>)]')
`
Here are the relative envs and deps in my computer.
Ubuntu 16.04
python2.7
theano 0.9.0
pygpu,libgpuarray 0.6.8

I goolge this issue but nothing help. I do not know what is wrong.

Please forgive my poor English ,if there is anything unclear you can ask me for details.
I will be so grateful for your reply.
thanks

Confused in the train of classifer.

I am so sorry to bother you again.
I have trained the snn_autonet with the delta_weight_mean : 2.05338878e-07,then i trained classifer.I got the 23.5% accuracy at first batch of 2000 examples, but i saw your result is 59.38%. Then i train the classifer with lr in your raw set ,but the last result is always around 75%~79%. I don't know what happened. I also want to use the snn_auto model in your files, but i can't load it successely. I am new in DL, there may be something i didn't notice. I really need your help, could you give me some advices. Thank you so much.

Here is the classifer trained results:

2017-12-29 09:50:42.822324: Learning rates LR: 1.000000 2017-12-29 09:52:42.108979: Iter: 2000 [0], loss: 99177.390625, acc: 0.00%, avg_loss: 85936.811722, avg_acc: 28.20% 2017-12-29 09:54:41.830846: Iter: 4000 [0], loss: 20514.828125, acc: 0.00%, avg_loss: 81864.085177, avg_acc: 34.17% 2017-12-29 09:56:40.925028: Iter: 6000 [0], loss: 0.000000, acc: 1.00%, avg_loss: 81793.218836, avg_acc: 37.23% 2017-12-29 09:58:42.632386: Iter: 8000 [0], loss: 0.000000, acc: 1.00%, avg_loss: 79121.567086, avg_acc: 40.06% 2017-12-29 10:00:41.175695: Iter: 10000 [0], loss: 42995.710938, acc: 0.00%, avg_loss: 78534.694568, avg_acc: 41.80% 2017-12-29 10:02:39.190052: Iter: 12000 [0], loss: 0.000000, acc: 1.00%, avg_loss: 77897.013161, avg_acc: 43.37% 2017-12-29 10:02:39.190443: Epoch 0: avg_Loss: 77903.505120136964, avg_Acc: 43.370280856738 2017-12-29 10:02:39.190583: Learning rates changed LR: 0.100000 2017-12-29 10:04:42.617513: Iter: 14000 [1], loss: 18558.640625, acc: 0.00%, avg_loss: 26327.748162, avg_acc: 69.40% 2017-12-29 10:06:40.323889: Iter: 16000 [1], loss: 0.000000, acc: 1.00%, avg_loss: 22216.912610, avg_acc: 71.53% 2017-12-29 10:08:40.542183: Iter: 18000 [1], loss: 0.000000, acc: 1.00%, avg_loss: 21290.121762, avg_acc: 72.17% 2017-12-29 10:10:39.691736: Iter: 20000 [1], loss: 0.000000, acc: 1.00%, avg_loss: 20656.107550, avg_acc: 72.12% 2017-12-29 10:12:36.612161: Iter: 22000 [1], loss: 0.000000, acc: 1.00%, avg_loss: 20444.464095, avg_acc: 72.05% 2017-12-29 10:14:35.092268: Iter: 24000 [1], loss: 118659.570312, acc: 0.00%, avg_loss: 20122.769527, avg_acc: 72.12% 2017-12-29 10:14:35.092541: Epoch 1: avg_Loss: 20124.446563906367, avg_Acc: 72.122676889741 2017-12-29 10:14:35.092582: Learning rates changed LR: 0.100000 2017-12-29 10:16:36.363787: Iter: 26000 [2], loss: 0.000000, acc: 1.00%, avg_loss: 17975.989564, avg_acc: 73.10% 2017-12-29 10:18:35.850549: Iter: 28000 [2], loss: 44473.710938, acc: 0.00%, avg_loss: 17481.193654, avg_acc: 73.25% 2017-12-29 10:20:34.975065: Iter: 30000 [2], loss: 0.000000, acc: 1.00%, avg_loss: 17638.474654, avg_acc: 73.12% 2017-12-29 10:22:36.304807: Iter: 32000 [2], loss: 0.000000, acc: 1.00%, avg_loss: 17455.829458, avg_acc: 72.91% 2017-12-29 10:24:34.476960: Iter: 34000 [2], loss: 0.000000, acc: 1.00%, avg_loss: 17744.024149, avg_acc: 72.76% 2017-12-29 10:26:32.921364: Iter: 36000 [2], loss: 0.000000, acc: 1.00%, avg_loss: 17528.401285, avg_acc: 72.91% 2017-12-29 10:26:32.921725: Epoch 2: avg_Loss: 17529.862106998906, avg_Acc: 72.914409534128 2017-12-29 10:26:32.921873: Learning rates changed LR: 0.010000 2017-12-29 10:28:39.264652: Iter: 38000 [3], loss: 0.000000, acc: 1.00%, avg_loss: 13054.521175, avg_acc: 75.95% 2017-12-29 10:30:26.309336: Iter: 40000 [3], loss: 0.000000, acc: 1.00%, avg_loss: 13008.920330, avg_acc: 76.38% 2017-12-29 10:32:11.410454: Iter: 42000 [3], loss: 0.000000, acc: 1.00%, avg_loss: 13880.511879, avg_acc: 76.25% 2017-12-29 10:34:05.807313: Iter: 44000 [3], loss: 23595.546875, acc: 0.00%, avg_loss: 13951.334126, avg_acc: 76.38% 2017-12-29 10:35:59.726245: Iter: 46000 [3], loss: 115823.546875, acc: 0.00%, avg_loss: 13987.278281, avg_acc: 76.33% 2017-12-29 10:37:50.667808: Iter: 48000 [3], loss: 0.000000, acc: 1.00%, avg_loss: 13714.742202, avg_acc: 76.51% 2017-12-29 10:37:50.668205: Epoch 3: avg_Loss: 13715.885192744245, avg_Acc: 76.514709559130 2017-12-29 10:37:50.668328: Learning rates changed LR: 0.001000 2017-12-29 10:39:45.801393: Iter: 50000 [4], loss: 21998.937500, acc: 0.00%, avg_loss: 14667.064186, avg_acc: 76.35% 2017-12-29 10:41:26.169617: Iter: 52000 [4], loss: 0.000000, acc: 1.00%, avg_loss: 13953.024168, avg_acc: 76.68% 2017-12-29 10:43:24.667357: Iter: 54000 [4], loss: 0.000000, acc: 1.00%, avg_loss: 13596.672170, avg_acc: 76.80% 2017-12-29 10:45:24.305483: Iter: 56000 [4], loss: 0.000000, acc: 1.00%, avg_loss: 13453.069836, avg_acc: 76.76% 2017-12-29 10:47:23.165318: Iter: 58000 [4], loss: 0.000000, acc: 1.00%, avg_loss: 13597.539448, avg_acc: 76.82% 2017-12-29 10:49:21.349746: Iter: 60000 [4], loss:0.000000, acc: 1.00%, avg_loss: 19883.241314, avg_acc: 76.33% 2017-12-20 10:37:11.733672: Epoch 4: avg_Loss: 19884.898389319776, avg_Acc: 76.331527627302 2017-12-20 10:37:11.733709: Learning rates changed LR: 0.001000 2017-12-20 10:38:41.183413: Iter: 62000 [5], loss: 0.000000, acc: 1.00%, avg_loss: 18197.470076, avg_acc: 79.40% 2017-12-20 10:40:07.714596: Iter: 64000 [5], loss: 0.000000, acc: 1.00%, avg_loss: 18597.421187, avg_acc: 78.80% 2017-12-20 10:41:39.236288: Iter: 66000 [5], loss: 87509.156250, acc: 0.00%, avg_loss: 19343.797669, avg_acc: 78.13% 2017-12-20 10:43:02.023565: Iter: 68000 [5], loss: 2268.468750, acc: 0.00%, avg_loss: 19525.549633, avg_acc: 78.16% 2017-12-20 10:44:27.446234: Iter: 70000 [5], loss: 0.000000, acc: 1.00%, avg_loss: 19540.495293, avg_acc: 78.36% 2017-12-20 10:45:55.687838: Iter: 72000 [5], loss: 7991.203125, acc: 0.00%, avg_loss: 19458.476607, avg_acc: 78.35% 2017-12-20 10:45:55.688114: Epoch 5: avg_Loss: 19460.098281627750, avg_Acc: 78.356529710809

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.