{"id":18850906,"url":"https://github.com/igitugraz/lsnn-official","last_synced_at":"2025-04-14T09:50:56.399Z","repository":{"id":84131730,"uuid":"190605123","full_name":"IGITUGraz/LSNN-official","owner":"IGITUGraz","description":"Long short-term memory Spiking Neural Networks","archived":false,"fork":false,"pushed_at":"2020-02-25T20:28:35.000Z","size":189,"stargazers_count":102,"open_issues_count":0,"forks_count":24,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-27T23:06:48.325Z","etag":null,"topics":["machine-learning","neuromorphic-computing","spiking-neural-networks"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause-clear","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IGITUGraz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-06T15:27:52.000Z","updated_at":"2025-03-13T01:36:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"86547c67-162c-4b1f-a984-4cc37f91bd4c","html_url":"https://github.com/IGITUGraz/LSNN-official","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IGITUGraz%2FLSNN-official","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IGITUGraz%2FLSNN-official/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IGITUGraz%2FLSNN-official/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IGITUGraz%2FLSNN-official/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IGITUGraz","download_url":"https://codeload.github.com/IGITUGraz/LSNN-official/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248859505,"owners_count":21173336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["machine-learning","neuromorphic-computing","spiking-neural-networks"],"created_at":"2024-11-08T03:32:32.158Z","updated_at":"2025-04-14T09:50:56.391Z","avatar_url":"https://github.com/IGITUGraz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## LSNN: Long short-term memory Spiking Neural Networks\n\nThis repository provides a tensorflow 1.12 library and a tutorial to train a recurrent spiking neural networks (ours is called LSNN).\nFor more details about LSNN see [1]. This model uses a method of network rewiring to keep a sparse connectivity during training, this method is called DEEP R and is described in [2]. Feel free to cite us if that's relevant.\n\n## Usage\nAfter installation load the LSNN library, load our implementation of the ALIF tensorflow cell (adaptive leaky integrate and fire), and use it in place of standard tensorflow 1.12 rnn cells:\n\n```python\nimport tensorflow as tf  \nimport lsnn  \n\n...\n\ncell =  lsnn.ALIF(num_of_inputs, num_of_outputs, ...)\noutputs, final_state = tf.nn.dynamic_rnn(cell, inputs, dtype=tf.float32)\n\nspikes = outputs[0]\nloss(spikes)\n```\n\nIn the folder `lsnn/` you may find the source code of the lsnn package. In the folder `bin/` there is a selection of tutorials. With `tutorial_sequential_mnist_with_LSNN.py`, you can reproduce Figure 1B from [1] and achieve above __96%__ accuracy on the __sequential MNIST__ task with an LSNN (the code may not reproduce exactlty the results published in [1]).  \n\nThe second tutorial `tutorial_storerecall_with_LSNN.py` solves a simpler task that runs in few minutes with CPUs. This simpler task is a good test to verify if a network model has long-short term memory. For a detailed description about the task we refer to the older version (v1) of the preprint [3].\n\n## Installation\n\nThe code is compatible with python 3.4 to 3.7 and tensorflow 1.7 to 1.12 (CPU and GPU versions).\n\n\u003e You can run the training scripts **without installation** by temporarily including the repo directory\n\u003e in your python path like so: `` PYTHONPATH=. python3 bin/tutorial_sequential_mnist_with_LSNN.py`` \n\nFrom the main folder run:  \n`` pip3 install --user .``  \nYou can now import the tensorflow cell called ALIF (for adaptive leakey integrate and fire) as well as the rewiring wrapper to update connectivity matrices after each call to the optimizer.\nWarning, the GPU compatible version of tensorflow is not part of the requirements by default.\nTo use GPUs one should also install it:\n ``pip3 install --user tensorflow-gpu``.\n\n## Troubleshooting\n\n### Possible incompatibility with tf.variable_scope(..., reuse=??)\nThe LIF and ALIF cells defined in `spiking_models.py` behave almost like any tensorflow cell. However, we define the tensorflow variables during initilization of the cell object instead of using the high level function `get_variables(...)` or `add_weights(...)` in Keras.  \n\nThis leads to some incompatibility with some deep learning frameworks because two objects of our cell classes will not share the same parameters using if they share the variable scope. To fix it, we recommend rewriting the cell definition in the style of Keras and tensorflow 2 rnn cells, but this solution is likely to break the compatibility with the rewiring package.\n\n### Wrong compilation of tensorflow\n\nIf the scripts fail with the following error:\n`` Illegal instruction (core dumped) ``\n\nIt is most probably due to the lack of AVX instructions on the machine you are using.\nA known workaround is to reinstall the LSNN package with older tensorflow version (1.5).\nChange requirements.txt to contain:\n\n`` tensorflow==1.5 ``\n\n## Credits\n\nThe code was written by Guillaume Bellec and Darjan Salaj at the IGI institute of TU Graz between 2017 and 2018. Anand Subramoney and Arjun Rao helped to improve the implementation.\n\n[1] Long short-term memory and Learning-to-learn in networks of spiking neurons  \nGuillaume Bellec*, Darjan Salaj*, Anand Subramoney*, Robert Legenstein, Wolfgang Maass  \nNIPS 2018, [[link]](http://papers.nips.cc/paper/7359-long-short-term-memory-and-learning-to-learn-in-networks-of-spiking-neurons) [[arxiv]](https://arxiv.org/abs/1803.09574  )\n(\\* equal contributions)\n\n[2] Deep Rewiring: Training very sparse deep networks  \nGuillaume Bellec, David Kappel, Wolfgang Maass, Robert Legenstein  \nICLR 2018, [[link]](https://openreview.net/forum?id=BJ_wN01C-) [[arxiv]](https://arxiv.org/abs/1711.05136)\n\n[3] Biologically inspired alternatives to backpropagation through time for learning in recurrent neural nets  \nGuillaume Bellec*, Franz Scherr*, Elias Hajek, Darjan Salaj, Robert Legenstein, and Wolfgang Maass  \narxiv 2019 [[arxiv]](https://arxiv.org/abs/1901.09049) [[v1 with store recall task]](https://arxiv.org/pdf/1901.09049v1.pdf)\n\n## Citing LSNN\n\n```\n@inproceedings{bellec2018long,\n  title={Long short-term memory and learning-to-learn in networks of spiking neurons},\n  author={Bellec, Guillaume and Salaj, Darjan and Subramoney, Anand and Legenstein, Robert and Maass, Wolfgang},\n  booktitle={Advances in Neural Information Processing Systems},\n  pages={787--797},\n  year={2018}\n}\n```\n\n## License\n\nLSNN-official is open source software and is licensed under the [BSD 3-Clause Clear License](https://spdx.org/licenses/BSD-3-Clause-Clear.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figitugraz%2Flsnn-official","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figitugraz%2Flsnn-official","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figitugraz%2Flsnn-official/lists"}