{"id":13648146,"url":"https://github.com/cortical-team/neko","last_synced_at":"2025-04-22T07:30:41.537Z","repository":{"id":217096809,"uuid":"363275520","full_name":"cortical-team/neko","owner":"cortical-team","description":null,"archived":false,"fork":false,"pushed_at":"2021-10-15T20:16:00.000Z","size":60,"stargazers_count":17,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-09T22:37:56.519Z","etag":null,"topics":["deep-learning","learning-algorithms","neuromorphic-computing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cortical-team.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":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-30T22:42:24.000Z","updated_at":"2023-05-27T16:02:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"b6bcf92f-0885-4c7c-a54c-5ef30b7f9863","html_url":"https://github.com/cortical-team/neko","commit_stats":null,"previous_names":["cortical-team/neko"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortical-team%2Fneko","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortical-team%2Fneko/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortical-team%2Fneko/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortical-team%2Fneko/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cortical-team","download_url":"https://codeload.github.com/cortical-team/neko/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250195033,"owners_count":21390230,"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":["deep-learning","learning-algorithms","neuromorphic-computing"],"created_at":"2024-08-02T01:04:00.275Z","updated_at":"2025-04-22T07:30:41.527Z","avatar_url":"https://github.com/cortical-team.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Neko: a Library for Exploring Neuromorphic Learning Rules\n\n## Paper\nhttps://arxiv.org/abs/2105.00324\n\n## Installation\n\n```bash\ngit clone https://github.com/cortical-team/neko.git\ncd neko\npip install -e .\n```\n\n## Code Example\nTrain a RSNN with ALIF neurons with e-prop on MNIST:\n\n```python\nfrom neko.backend import pytorch_backend as backend\nfrom neko.datasets import MNIST\nfrom neko.evaluator import Evaluator\nfrom neko.layers import ALIFRNNModel\nfrom neko.learning_rules import Eprop\nfrom neko.trainers import Trainer\n\nx_train, y_train, x_test, y_test = MNIST().load()\nx_train, x_test = x_train / 255., x_test / 255.\n\nmodel = ALIFRNNModel(128, 10, backend=backend, task_type='classification', return_sequence=False)\nevaluated_model = Evaluator(model=model, loss='categorical_crossentropy', metrics=['accuracy', 'firing_rate'])\nalgo = Eprop(evaluated_model, mode='symmetric')\ntrainer = Trainer(algo)\ntrainer.train(x_train, y_train, epochs=30)\n```\n\n## Example Scripts\n### Learning with e-prop\nTraining on the MNIST dataset with the same setting above, but more options available.\nFor example, you can learn with BPTT and three variations of e-prop.\n```bash\npython examples/mnist.py\n```\n\nTraining on the TIMIT dataset. You need to place the `timit_processed` folder the same place as the script containing the processed dataset\nproduced by a [script](https://github.com/IGITUGraz/eligibility_propagation/blob/master/Figure_2_TIMIT/timit_processing.py) from the original authors of e-prop.\n```bash\npython examples/timit.py\n```\n\nRegularization enabled:\n```bash\npython timit.py --reg --eprop_mode symmetric --reg_coeff 5e-7\n# Test: {'loss': 0.8918977379798889, 'accuracy': 0.7501428091397849, 'firing_rate': 12.973159790039062}\n```\nFaster training (~7.5X, 28s per epoch with RTX3090) with regularization enabled:\n```bash\npython timit.py --reg --eprop_mode symmetric --reg_coeff 3e-8 --batch_size 256  --learning_rate 0.01\n# Test: {'loss': 0.8605409860610962, 'accuracy': 0.7542506720430108, 'firing_rate': 13.105131149291992}\n```\n\n### Probabilistic learning with HMC\nTraining on the [MNIST-1D dataset](https://github.com/greydanus/mnist1d) with HMC:\n```bash\npython examples/mnist_1d_hmc.py\n```\n### Analogue Neural Network Training with Manhattan Rule\nTraining on the MNIST dataset with the simple Manhattan rule or Mahattan material rule:\n```bash\npython examples/mnist_manhattan.py\n```\n\n### Gradient Comparison Tool\nCompare the gradients from BPTT with the three varients of e-prop:\n```bash\npython examples/mnist_gradcompare.py\n```\nThis is a visualization from the results of the script above.\n\n![](https://i.ibb.co/M2XDQVY/grads.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcortical-team%2Fneko","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcortical-team%2Fneko","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcortical-team%2Fneko/lists"}