Skip to content

Commit

Permalink
Merge pull request #74 from Hananel-Hazan/dan
Browse files Browse the repository at this point in the history
Cleaning up Nodes code, adding current-based LIF, lots of refactoring.
  • Loading branch information
Dan Saunders committed Jun 12, 2018
2 parents 2c42de5 + 0104b0b commit b3a1c90
Show file tree
Hide file tree
Showing 15 changed files with 857 additions and 316 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A Python package used for simulating spiking neural networks (SNNs) on CPUs or G

BindsNET is a spiking neural network simulation library geared towards the development of biologically inspired algorithms for machine learning.

This package is used as part of ongoing research on applying SNNs to machine learning (ML) and reinforcement learning (RL) problems in the [Biologically Inspired Neural & Dynamical Systems (BINDS) lab](http://binds.cs.umass.edu/).
This package is used as part of ongoing research on applying SNNs to machine learning (ML) and reinforcement learning (RL) problems in the [Biologically Inspired Neural & Dynamical Systems (BINDS) lab](http://binds.cs.umass.edu/).

[![Build Status](https://travis-ci.com/Hananel-Hazan/bindsnet.svg?token=trym5Uzx1rs9Ez2yENEF&branch=master)](https://travis-ci.com/Hananel-Hazan/bindsnet)
[![Documentation Status](https://readthedocs.org/projects/bindsnet-docs/badge/?version=latest)](https://bindsnet-docs.readthedocs.io/?badge=latest)
Expand Down Expand Up @@ -78,8 +78,25 @@ We are interested in applying SNNs to ML and RL problems. We use STDP to modify

We have provided some simple starter scripts for doing unsupervised learning (learning a fully-connected or convolutional representation via STDP), supervised learning (clamping output neurons to desired spiking behavior depending on data labels), and reinforcement learning (converting observations from the Atari game Space Invaders to input to an SNN, and converting network activity back to actions in the game).

## References
Hananel Hazan, Daniel J. Saunders, Hassaan Khan, Darpan T. Sanghavi, Hava T. Siegelmann, Robert Kozma, [BindsNET: A machine learning-oriented spiking neural networks library in Python.](https://arxiv.org/abs/1806.01423) 2018, Arxiv.
## Citation

If you use BindsNET in your research, please cite the following [article](https://arxiv.org/abs/1806.01423):

```
@ARTICLE{2018arXiv180601423H,
author = {{Hazan}, H. and {Saunders}, D.~J. and {Khan}, H. and {Sanghavi}, D.~T. and
{Siegelmann}, H.~T. and {Kozma}, R.},
title = "{BindsNET: A machine learning-oriented spiking neural networks library in Python}",
journal = {ArXiv e-prints},
archivePrefix = "arXiv",
eprint = {1806.01423},
keywords = {Computer Science - Neural and Evolutionary Computing, Quantitative Biology - Neurons and Cognition},
year = 2018,
month = jun,
adsurl = {http://adsabs.harvard.edu/abs/2018arXiv180601423H},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
```

## Contributors

Expand Down
152 changes: 105 additions & 47 deletions bindsnet/analysis/plotting.py

Large diffs are not rendered by default.

35 changes: 22 additions & 13 deletions bindsnet/analysis/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ def plot_weights_movie(ws, sample_every=1):
Inputs:
| :code:`ws` (:code:`numpy.array`): Numpy array of shape :code:`[N_examples, source, target, time]`
| :code:`sample_every` (:code:`int`): Sub-sample using this parameter. For example if :code:`time` is
too large (500), set this parameter to 20 to sample weights
every 20 iterations.
| :code:`ws` (:code:`numpy.array`): Numpy array
of shape :code:`[n_examples, source, target, time]`
| :code:`sample_every` (:code:`int`): Sub-sample using this parameter.
"""
weights = []

Expand Down Expand Up @@ -49,10 +48,13 @@ def plot_spike_trains_for_example(spikes, n_ex=None, top_k=None, indices=None):
Inputs:
| :code:`spikes` (:code:`torch.Tensor (n_examples, n_neurons, time)`): Spiking train data for a population of neurons for one example.
| :code:`n_ex` (:code:`int`): Allows user to pick which example to plot spikes for. Must be >= 0.
| :code:`spikes` (:code:`torch.Tensor (n_examples, n_neurons, time)`):
Spiking train data for a population of neurons for one example.
| :code:`n_ex` (:code:`int`): Allows user to pick
which example to plot spikes for. Must be >= 0.
| :code:`top_k` (:code:`int`): Plot k neurons that spiked the most for n_ex example.
| :code:`indices` (:code:`list(int)`): Plot specific neurons' spiking activity instead of top_k. Meant to replace top_k.
| :code:`indices` (:code:`list(int)`): Plot specific neurons'
spiking activity instead of top_k. Meant to replace top_k.
'''

assert (n_ex is not None and n_ex >= 0 and n_ex < spikes.shape[0])
Expand Down Expand Up @@ -84,11 +86,16 @@ def plot_voltage(voltage, n_ex=0, n_neuron=0, time=None, threshold=None):
Inputs:
| :code:`voltage` (:code:`torch.Tensor` or :code:`numpy.array`): Tensor or array of shape :code:`[n_examples, n_neurons, time]`.
| :code:`n_ex` (:code:`int`): Allows user to pick which example to plot voltage for.
| :code:`n_neuron` (:code:`int`): Neuron index for which to plot voltages for.
| :code:`time` (:code:`tuple(int)`): Plot spiking activity of neurons between the given range of time.
| :code:`threshold` (:code:`float`): Neuron spiking threshold. Will be shown on the plot.
| :code:`voltage` (:code:`torch.Tensor` or :code:`numpy.array`):
Tensor or array of shape :code:`[n_examples, n_neurons, time]`.
| :code:`n_ex` (:code:`int`): Allows user
to pick which example to plot voltage for.
| :code:`n_neuron` (:code:`int`): Neuron
index for which to plot voltages for.
| :code:`time` (:code:`tuple(int)`): Plot spiking
activity of neurons between the given range of time.
| :code:`threshold` (:code:`float`): Neuron
spiking threshold. Will be shown on the plot.
'''

assert (n_ex >= 0 and n_neuron >= 0)
Expand All @@ -105,7 +112,9 @@ def plot_voltage(voltage, n_ex=0, n_neuron=0, time=None, threshold=None):

plt.figure()
plt.plot(voltage[n_ex, n_neuron, timer])
plt.xlabel('Simulation Time'); plt.ylabel('Voltage'); plt.title('Membrane voltage of neuron %d for example %d'%(n_neuron, n_ex+1))
plt.xlabel('Simulation Time')
plt.ylabel('Voltage')
plt.title('Membrane voltage of neuron %d for example %d' % (n_neuron, n_ex + 1))
locs, labels = plt.xticks()
locs = range(int(locs[1]), int(locs[-1]), 10)
plt.xticks(locs, time_ticks)
Expand Down

0 comments on commit b3a1c90

Please sign in to comment.