===========
PymoNNtorch
===========
.. image:: https://raw.githubusercontent.com/cnrl/PymoNNtorch/main/docs/_images/pymoNNtorch-logo-t-256.png
:width: 256
:alt: pymonntorch logo
|
.. image:: https://img.shields.io/pypi/v/pymonntorch.svg
:target: https://pypi.python.org/pypi/pymonntorch
.. .. image:: https://img.shields.io/travis/cnrl/pymonntorch.svg
.. :target: https://travis-ci.com/cnrl/pymonntorch
.. image:: https://readthedocs.org/projects/pymonntorch/badge/?version=latest
:target: https://pymonntorch.readthedocs.io/en/latest/?version=latest
:alt: Documentation Status
PymoNNtorch is a *Pytorch*-adapted version of `PymoNNto <https://github.com/trieschlab/PymoNNto>`_.
* Free software: MIT license
* Documentation: https://pymonntorch.readthedocs.io.
Features
--------
* Use ``torch`` tensors and Pytorch-like syntax to create a spiking neural network (SNN).
* Simulate an SNN on CPU or GPU.
* Define dynamics of SNN components as ``Behavior`` modules.
* Control over the order of applying different behaviors in each simulation time step.
Usage
-----
You can use the same syntax as ``PymoNNto`` to create you network:
.. code-block:: python
from pymonntorch import *
net = Network()
ng = NeuronGroup(net=net, tag="my_neuron", size=100, behavior=None)
SynapseGroup(src=ng, dst=ng, net=net, tag="recurrent_synapse")
net.initialize()
net.simulate_iterations(1000)
Similarly, you can write your own ``Behavior`` Modules with the same logic as ``PymoNNto``; except using ``torch`` tensors instead of ``numpy`` ndarrays.
.. code-block:: python
from pymonntorch import *
class BasicBehavior(Behavior):
def initialize(self, neurons):
super().initialize(neurons)
neurons.voltage = neurons.vector(mode="zeros")
self.threshold = 1.0
def forward(self, neurons):
firing = neurons.voltage >= self.threshold
neurons.spike = firing.byte()
neurons.voltage[firing] = 0.0 # reset
neurons.voltage *= 0.9 # voltage decay
neurons.voltage += neurons.vector(mode="uniform", density=0.1)
class InputBehavior(Behavior):
def initialize(self, neurons):
super().initialize(neurons)
for synapse in neurons.afferent_synapses['GLUTAMATE']:
synapse.W = synapse.matrix('uniform', density=0.1)
synapse.enabled = synapse.W > 0
def forward(self, neurons):
for synapse in neurons.afferent_synapses['GLUTAMATE']:
neurons.voltage += synapse.W@synapse.src.spike.float() / synapse.src.size * 10
net = Network()
ng = NeuronGroup(net=net,
size=100,
behavior={
1: BasicBehavior(),
2: InputBehavior(),
9: Recorder(['voltage']),
10: EventRecorder(['spike'])
})
SynapseGroup(ng, ng, net, tag='GLUTAMATE')
net.initialize()
net.simulate_iterations(1000)
import matplotlib.pyplot as plt
plt.plot(net['voltage',0][:, :10])
plt.show()
plt.plot(net['spike.t',0], net['spike.i',0], '.k')
plt.show()
Credits
-------
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
It changes the codebase of `PymoNNto <https://github.com/trieschlab/PymoNNto>`_ to use ``torch`` rather than ``numpy`` and ``tensorflow numpy``.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
=======
History
=======
0.1.3 (2023-08-16)
* BREAKING CHANGE: `Network` no longer accept settings. Individual setting are now argument for Network.
* Bugg fixes.
0.1.2 (2023-06-14)
* `tensor` method for NetworkObject
0.1.1 (2023-05-26)
------------------
* Every NetworkObject can have a recorder behavior.
* Network settings accept "index" entry.
* Bug fixes and general improvement.
0.1.0 (2023-03-17)
------------------
* Repository made public.
Raw data
{
"_id": null,
"home_page": "https://github.com/cnrl/PymoNNtorch",
"name": "pymonntorch",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "pymonntorch",
"author": "Computational Neuroscience Research Laboratory",
"author_email": "ashenatena@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/5a/2b/51e4a399d5227de611bcce771d591641272a9a60578b8c801766c78228e8/pymonntorch-0.1.3.tar.gz",
"platform": null,
"description": "===========\nPymoNNtorch\n===========\n\n.. image:: https://raw.githubusercontent.com/cnrl/PymoNNtorch/main/docs/_images/pymoNNtorch-logo-t-256.png\n :width: 256\n :alt: pymonntorch logo\n\n|\n\n\n.. image:: https://img.shields.io/pypi/v/pymonntorch.svg\n :target: https://pypi.python.org/pypi/pymonntorch\n\n.. .. image:: https://img.shields.io/travis/cnrl/pymonntorch.svg\n.. :target: https://travis-ci.com/cnrl/pymonntorch\n\n.. image:: https://readthedocs.org/projects/pymonntorch/badge/?version=latest\n :target: https://pymonntorch.readthedocs.io/en/latest/?version=latest\n :alt: Documentation Status\n\n\n\n\nPymoNNtorch is a *Pytorch*-adapted version of `PymoNNto <https://github.com/trieschlab/PymoNNto>`_.\n\n\n* Free software: MIT license\n* Documentation: https://pymonntorch.readthedocs.io.\n\n\nFeatures\n--------\n\n* Use ``torch`` tensors and Pytorch-like syntax to create a spiking neural network (SNN).\n* Simulate an SNN on CPU or GPU.\n* Define dynamics of SNN components as ``Behavior`` modules.\n* Control over the order of applying different behaviors in each simulation time step.\n\nUsage\n-----\n\nYou can use the same syntax as ``PymoNNto`` to create you network:\n\n.. code-block:: python\n\n from pymonntorch import *\n\n net = Network()\n ng = NeuronGroup(net=net, tag=\"my_neuron\", size=100, behavior=None)\n SynapseGroup(src=ng, dst=ng, net=net, tag=\"recurrent_synapse\")\n net.initialize()\n net.simulate_iterations(1000)\n\n\nSimilarly, you can write your own ``Behavior`` Modules with the same logic as ``PymoNNto``; except using ``torch`` tensors instead of ``numpy`` ndarrays.\n\n.. code-block:: python\n\n from pymonntorch import *\n\n class BasicBehavior(Behavior):\n def initialize(self, neurons):\n super().initialize(neurons)\n neurons.voltage = neurons.vector(mode=\"zeros\")\n self.threshold = 1.0\n\n def forward(self, neurons):\n firing = neurons.voltage >= self.threshold\n neurons.spike = firing.byte()\n neurons.voltage[firing] = 0.0 # reset\n \n neurons.voltage *= 0.9 # voltage decay\n neurons.voltage += neurons.vector(mode=\"uniform\", density=0.1)\n\n class InputBehavior(Behavior):\n def initialize(self, neurons):\n super().initialize(neurons)\n for synapse in neurons.afferent_synapses['GLUTAMATE']:\n synapse.W = synapse.matrix('uniform', density=0.1)\n synapse.enabled = synapse.W > 0\n\n def forward(self, neurons):\n for synapse in neurons.afferent_synapses['GLUTAMATE']:\n neurons.voltage += synapse.W@synapse.src.spike.float() / synapse.src.size * 10\n\n net = Network()\n ng = NeuronGroup(net=net,\n size=100, \n behavior={\n 1: BasicBehavior(),\n 2: InputBehavior(),\n 9: Recorder(['voltage']),\n 10: EventRecorder(['spike'])\n })\n SynapseGroup(ng, ng, net, tag='GLUTAMATE')\n net.initialize()\n net.simulate_iterations(1000)\n\n import matplotlib.pyplot as plt\n\n plt.plot(net['voltage',0][:, :10])\n plt.show()\n\n plt.plot(net['spike.t',0], net['spike.i',0], '.k')\n plt.show()\n\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\nIt changes the codebase of `PymoNNto <https://github.com/trieschlab/PymoNNto>`_ to use ``torch`` rather than ``numpy`` and ``tensorflow numpy``.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n=======\nHistory\n=======\n\n0.1.3 (2023-08-16)\n\n* BREAKING CHANGE: `Network` no longer accept settings. Individual setting are now argument for Network.\n* Bugg fixes.\n\n\n0.1.2 (2023-06-14)\n\n* `tensor` method for NetworkObject\n\n\n0.1.1 (2023-05-26)\n------------------\n\n* Every NetworkObject can have a recorder behavior.\n* Network settings accept \"index\" entry.\n* Bug fixes and general improvement.\n\n\n0.1.0 (2023-03-17)\n------------------\n\n* Repository made public.\n",
"bugtrack_url": null,
"license": "MIT license",
"summary": "PymoNNtorch is a Pytorch version of PymoNNto",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/cnrl/PymoNNtorch"
},
"split_keywords": [
"pymonntorch"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "189e3c82afdd96b85e66b12003c7bdb936738c3ed88c6835f03ec0bd8b4dd7c1",
"md5": "6e04cca53b51fdec7783c1985cdcf375",
"sha256": "329bb0bdfd2ce868fc6cee8639b5e876842db40ea00e44f3093f8b2972fd49e8"
},
"downloads": -1,
"filename": "pymonntorch-0.1.3-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "6e04cca53b51fdec7783c1985cdcf375",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.8",
"size": 37722,
"upload_time": "2023-08-16T15:11:00",
"upload_time_iso_8601": "2023-08-16T15:11:00.496532Z",
"url": "https://files.pythonhosted.org/packages/18/9e/3c82afdd96b85e66b12003c7bdb936738c3ed88c6835f03ec0bd8b4dd7c1/pymonntorch-0.1.3-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5a2b51e4a399d5227de611bcce771d591641272a9a60578b8c801766c78228e8",
"md5": "4883283041f44be6092be49978c6404d",
"sha256": "920e9f35af328270ebfaf519ef8e0ad32121dc5907f0204df405db647d7a4d66"
},
"downloads": -1,
"filename": "pymonntorch-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "4883283041f44be6092be49978c6404d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 274028,
"upload_time": "2023-08-16T15:11:02",
"upload_time_iso_8601": "2023-08-16T15:11:02.523346Z",
"url": "https://files.pythonhosted.org/packages/5a/2b/51e4a399d5227de611bcce771d591641272a9a60578b8c801766c78228e8/pymonntorch-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-16 15:11:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cnrl",
"github_project": "PymoNNtorch",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "pymonntorch"
}