PymoNNtorch
PymoNNtorch is a Pytorch-adapted version of 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:
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.
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(src=ng, dst=ng, net=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 to use torch rather than numpy and tensorflow numpy.
History
0.1.4 (2024-03-16)
Bug fixes.
Src and dst can be None for syanpses.
Hierarchical structure.
0.1.3 (2023-08-16)
BREAKING CHANGE: Network no longer accept settings. Individual setting are now argument for Network.
Bug 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.
Metadata
Release files for pymonntorch 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pymonntorch-0.1.5.tar.gz | 276.0 kB | Without provenance | Details for pymonntorch-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pymonntorch-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for pymonntorch-0.1.5-py3-none-any.whl |
Total release size: 313.8 kB
Release files / pymonntorch-0.1.5.tar.gz
| Download URL | pymonntorch-0.1.5.tar.gz |
|---|---|
| Size | 276.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6dc83dd0b55b2b2e0064d3205066b77bbc49940756ad17fce8123a04ffc48b07
|
|
BLAKE2b-256 checksum How to use checksums |
9f623e8bc26d1c75e7e13a1c20409f0b39b5662617e19e001a4b88e9c043d272
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / pymonntorch-0.1.5-py3-none-any.whl
| Download URL | pymonntorch-0.1.5-py3-none-any.whl |
|---|---|
| Size | 37.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71f0f41fcae84d349315ca4176c93875a7604eaa873827d291b3f8f8f89a8fa9
|
|
BLAKE2b-256 checksum How to use checksums |
57ad2b200b97d90fffb4fe2426379a9371ba5c2682b8cadc8f67868e69c0943f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for pymonntorch 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.