ngclearn 1.0b0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ngclearn-1.0b0/AUTHORS +15 -0
- ngclearn-1.0b0/LICENSE +29 -0
- ngclearn-1.0b0/PKG-INFO +188 -0
- ngclearn-1.0b0/README.md +150 -0
- ngclearn-1.0b0/ngclearn/__init__.py +23 -0
- ngclearn-1.0b0/ngclearn/commands/__init__.py +1 -0
- ngclearn-1.0b0/ngclearn/components/__init__.py +19 -0
- ngclearn-1.0b0/ngclearn/components/baseComponentTemplate.py +47 -0
- ngclearn-1.0b0/ngclearn/components/input_encoders/__init__.py +2 -0
- ngclearn-1.0b0/ngclearn/components/input_encoders/bernoulliCell.py +123 -0
- ngclearn-1.0b0/ngclearn/components/input_encoders/poissonCell.py +132 -0
- ngclearn-1.0b0/ngclearn/components/neurons/__init__.py +9 -0
- ngclearn-1.0b0/ngclearn/components/neurons/graded/__init__.py +4 -0
- ngclearn-1.0b0/ngclearn/components/neurons/graded/gaussianErrorCell.py +174 -0
- ngclearn-1.0b0/ngclearn/components/neurons/graded/laplacianErrorCell.py +174 -0
- ngclearn-1.0b0/ngclearn/components/neurons/graded/rateCell.py +201 -0
- ngclearn-1.0b0/ngclearn/components/neurons/spiking/LIFCell.py +305 -0
- ngclearn-1.0b0/ngclearn/components/neurons/spiking/__init__.py +5 -0
- ngclearn-1.0b0/ngclearn/components/neurons/spiking/izhikevichCell.py +150 -0
- ngclearn-1.0b0/ngclearn/components/neurons/spiking/quadLIFCell.py +327 -0
- ngclearn-1.0b0/ngclearn/components/neurons/spiking/sLIFCell.py +378 -0
- ngclearn-1.0b0/ngclearn/components/other/__init__.py +2 -0
- ngclearn-1.0b0/ngclearn/components/other/expKernel.py +129 -0
- ngclearn-1.0b0/ngclearn/components/other/varTrace.py +150 -0
- ngclearn-1.0b0/ngclearn/components/synapses/__init__.py +3 -0
- ngclearn-1.0b0/ngclearn/components/synapses/hebbian/__init__.py +3 -0
- ngclearn-1.0b0/ngclearn/components/synapses/hebbian/expSTDPSynapse.py +234 -0
- ngclearn-1.0b0/ngclearn/components/synapses/hebbian/hebbianSynapse.py +334 -0
- ngclearn-1.0b0/ngclearn/components/synapses/hebbian/traceSTDPSynapse.py +264 -0
- ngclearn-1.0b0/ngclearn/components/wrappers.py +8 -0
- ngclearn-1.0b0/ngclearn/utils/__init__.py +0 -0
- ngclearn-1.0b0/ngclearn/utils/density/__init__.py +0 -0
- ngclearn-1.0b0/ngclearn/utils/density/gmm.py +82 -0
- ngclearn-1.0b0/ngclearn/utils/io_utils.py +67 -0
- ngclearn-1.0b0/ngclearn/utils/model_utils.py +274 -0
- ngclearn-1.0b0/ngclearn/utils/optim/__init__.py +2 -0
- ngclearn-1.0b0/ngclearn/utils/optim/adam.py +88 -0
- ngclearn-1.0b0/ngclearn/utils/optim/opt.py +25 -0
- ngclearn-1.0b0/ngclearn/utils/optim/sgd.py +38 -0
- ngclearn-1.0b0/ngclearn/utils/patch_utils.py +79 -0
- ngclearn-1.0b0/ngclearn/utils/viz/__init__.py +0 -0
- ngclearn-1.0b0/ngclearn/utils/viz/dim_reduce.py +91 -0
- ngclearn-1.0b0/ngclearn/utils/viz/raster.py +177 -0
- ngclearn-1.0b0/ngclearn/utils/viz/synapse_plot.py +151 -0
- ngclearn-1.0b0/ngclearn.egg-info/PKG-INFO +188 -0
- ngclearn-1.0b0/ngclearn.egg-info/SOURCES.txt +50 -0
- ngclearn-1.0b0/ngclearn.egg-info/dependency_links.txt +1 -0
- ngclearn-1.0b0/ngclearn.egg-info/requires.txt +9 -0
- ngclearn-1.0b0/ngclearn.egg-info/top_level.txt +4 -0
- ngclearn-1.0b0/pyproject.toml +51 -0
- ngclearn-1.0b0/requirements.txt +9 -0
- ngclearn-1.0b0/setup.cfg +4 -0
ngclearn-1.0b0/AUTHORS
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# This file contains an official list of authors of this framework.
|
|
2
|
+
|
|
3
|
+
# Names should be added to this file as:
|
|
4
|
+
# Name or Organization <email address>
|
|
5
|
+
# The email address is not required for organizations.
|
|
6
|
+
|
|
7
|
+
Core Team
|
|
8
|
+
Alexander Ororbia <ago@cs.rit.edu>
|
|
9
|
+
Ankur Mali <aam35@psu.edu>
|
|
10
|
+
William Gebhardt <wdg1351@rit.edu>
|
|
11
|
+
|
|
12
|
+
Contributors
|
|
13
|
+
Maxbeth2 (Ohas)
|
|
14
|
+
pagrawal-psu
|
|
15
|
+
pulinagrawal
|
ngclearn-1.0b0/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021, The Neural Adaptive Computing Laboratory
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
ngclearn-1.0b0/PKG-INFO
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ngclearn
|
|
3
|
+
Version: 1.0b0
|
|
4
|
+
Summary: Simulation software for building and analyzing arbitrary predictive coding, spiking network, and biomimetic neural systems.
|
|
5
|
+
Author-email: Alexander Ororbia <ago@cs.rit.edu>, William Gebhardt <wdg1351@rit.edu>
|
|
6
|
+
License: BSD-3-Clause License
|
|
7
|
+
Project-URL: Homepage, https://github.com/NACLab/ngc-learn
|
|
8
|
+
Project-URL: Documentation, https://ngc-learn.readthedocs.io/
|
|
9
|
+
Project-URL: Lab Page, https://www.cs.rit.edu/~ago/nac_lab.html
|
|
10
|
+
Project-URL: Changelog, https://github.com/NACLab/ngc-learn/blob/main/history.txt
|
|
11
|
+
Keywords: python,ngc-learn,predictive-processing,predictive-coding,jax,spiking-neural-networks,biomimetics,bionics,computational-neuroscience
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Programming Language :: Python
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Operating System :: Unix
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
License-File: AUTHORS
|
|
29
|
+
Requires-Dist: numpy>=1.26.0
|
|
30
|
+
Requires-Dist: scikit-learn>=0.24.2
|
|
31
|
+
Requires-Dist: scipy>=1.7.0
|
|
32
|
+
Requires-Dist: matplotlib>=3.8.0
|
|
33
|
+
Requires-Dist: patchify
|
|
34
|
+
Requires-Dist: jax>=0.4.18
|
|
35
|
+
Requires-Dist: jaxlib>=0.4.18
|
|
36
|
+
Requires-Dist: ngcsimlib>=0.2.b1
|
|
37
|
+
Requires-Dist: imageio>=2.31.5
|
|
38
|
+
|
|
39
|
+
[](https://www.python.org/downloads)[](https://opensource.org/licenses/BSD-3-Clause)[](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity)[](http://ngc-learn.readthedocs.io/en/latest/?badge=latest)[](https://zenodo.org/badge/latestdoi/483413212)
|
|
40
|
+
|
|
41
|
+
<img src="docs/images/ngc-learn-logo.png" width="300">
|
|
42
|
+
|
|
43
|
+
<b>ngc-learn</b> is a Python library for building, simulating, and analyzing
|
|
44
|
+
biomimetic systems, neurobiological agents, spiking neuronal networks,
|
|
45
|
+
predictive coding circuitry, and models that learn via biologically-plausible
|
|
46
|
+
forms of credit assignment. This simulation toolkit is built on top of JAX and is
|
|
47
|
+
distributed under the 3-Clause BSD license.
|
|
48
|
+
|
|
49
|
+
It is currently maintained by the
|
|
50
|
+
<a href="https://www.cs.rit.edu/~ago/nac_lab.html">Neural Adaptive Computing (NAC) laboratory</a>.
|
|
51
|
+
|
|
52
|
+
## <b>Documentation</b>
|
|
53
|
+
|
|
54
|
+
Official documentation, including tutorials, can be found
|
|
55
|
+
<a href="https://ngc-learn.readthedocs.io/en/latest/#">here</a>.
|
|
56
|
+
|
|
57
|
+
The official blog-post related to the source paper behind this software library
|
|
58
|
+
can be found
|
|
59
|
+
<a href="https://go.nature.com/3rgl1K8">here</a>.<br>
|
|
60
|
+
You can find the related paper <a href="https://www.nature.com/articles/s41467-022-29632-7">right here</a>, which
|
|
61
|
+
was selected to appear in the Nature <i>Neuromorphic Hardware and Computing Collection</i> in 2023 and was
|
|
62
|
+
chosen as one of the <i>Editors' Highlights for Applied Physics and Mathematics</i> in 2022.
|
|
63
|
+
|
|
64
|
+
<!--The technical report going over the theoretical underpinnings of the
|
|
65
|
+
NGC framework can be found here. TO BE RELEASED SOON. -->
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
### Dependencies
|
|
70
|
+
|
|
71
|
+
ngc-learn requires:
|
|
72
|
+
1) Python (>=3.10)
|
|
73
|
+
2) NumPy (>=1.26.0)
|
|
74
|
+
3) SciPy (>=1.7.0)
|
|
75
|
+
4) ngcsimlib (>=0.2.b1), (visit official page <a href="https://github.com/NACLab/ngc-sim-lib">here</a>)
|
|
76
|
+
5) JAX (>= 0.4.18) (to enable GPU use, make sure to install one of the CUDA variants)
|
|
77
|
+
<!--
|
|
78
|
+
5) scikit-learn (>=1.3.1) if using `ngclearn.utils.density`
|
|
79
|
+
6) matplotlib (>=3.4.3) if using `ngclearn.utils.viz`
|
|
80
|
+
6) networkx (>=2.6.3) (currently optional but required if using `ngclearn.utils.experimental.viz_utils`)
|
|
81
|
+
7) pyviz (>=0.2.0) (currently optional but required if using `ngclearn.utils.experimental.viz_utils`)
|
|
82
|
+
-->
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
ngc-learn 1.0.beta0 and later require Python 3.10 or newer as well as ngcsimlib >=0.2.b1.
|
|
86
|
+
ngc-learn's plotting capabilities (routines within `ngclearn.utils.viz`) require
|
|
87
|
+
Matplotlib (>=3.8.0) and imageio (>=2.31.5) and both plotting and density estimation
|
|
88
|
+
tools (routines within ``ngclearn.utils.density``) will require Scikit-learn (>=0.24.2).
|
|
89
|
+
Many of the tutorials will require Matplotlib (>=3.8.0), imageio (>=2.31.5), and Scikit-learn (>=0.24.2).
|
|
90
|
+
<!-- (Note: if using the `_generate_patch_set()` within the
|
|
91
|
+
image patching utilities, then Patchify will be needed).-->
|
|
92
|
+
|
|
93
|
+
### User Installation
|
|
94
|
+
|
|
95
|
+
<i>Setup</i>: The easiest way to install ngc-learn (CPU version) is through <code>pip</code>:
|
|
96
|
+
<pre>
|
|
97
|
+
$ python install ngclearn
|
|
98
|
+
</pre>
|
|
99
|
+
|
|
100
|
+
The documentation includes more detailed
|
|
101
|
+
<a href="https://ngc-learn.readthedocs.io/en/latest/installation.html">installation instructions</a>.
|
|
102
|
+
Note that this library was developed on Ubuntu 20.04 and tested on Ubuntu(s) 18.04 and 20.04.
|
|
103
|
+
|
|
104
|
+
<!--
|
|
105
|
+
<i>Setup:</i> To install ngc-learn, you can run (at the top-level of the
|
|
106
|
+
the <code>ngclearn</code> directory) the following bash command:
|
|
107
|
+
<pre>
|
|
108
|
+
$ python install .
|
|
109
|
+
</pre>
|
|
110
|
+
|
|
111
|
+
Running the above pip install will automatically install the CPU
|
|
112
|
+
version of JAX. If you want to use the GPU version instead, make sure to,
|
|
113
|
+
before running the above, to install JAX via the correct pip command
|
|
114
|
+
with the proper CUDA flags (depending on which CUDA is configured for your system)
|
|
115
|
+
as per their
|
|
116
|
+
<a href="https://jax.readthedocs.io/en/latest/installation.html">installation instructions</a>.
|
|
117
|
+
-->
|
|
118
|
+
|
|
119
|
+
<!--
|
|
120
|
+
(If you want to set up/install dependencies a priori, try running
|
|
121
|
+
`$ pip install -r requirements.txt` first before pip installing ngc-learn.)
|
|
122
|
+
-->
|
|
123
|
+
|
|
124
|
+
If the installation was successful, you should see the following if you test
|
|
125
|
+
it against your Python interpreter, i.e., run the <code>$ python</code> command
|
|
126
|
+
and complete the following sequence of steps as depicted in the screenshot below:<br>
|
|
127
|
+
<img src="docs/images/test_ngclearn_install.png" width="512">
|
|
128
|
+
|
|
129
|
+
<i>Note:</i> For access to the previous Tensorflow-2 version of ngc-learn (of
|
|
130
|
+
which we no longer support), please visit the repo for
|
|
131
|
+
<a href="https://github.com/NACLab/ngc-learn-legacy"><i>ngc-learn-legacy</i></a>.
|
|
132
|
+
|
|
133
|
+
## <b>Attribution:</b>
|
|
134
|
+
|
|
135
|
+
If you use this code in any form in your project(s), please cite its source
|
|
136
|
+
paper (as well as ngc-learn's official software citation):
|
|
137
|
+
<pre>
|
|
138
|
+
@article{Ororbia2022,
|
|
139
|
+
author={Ororbia, Alexander and Kifer, Daniel},
|
|
140
|
+
title={The neural coding framework for learning generative models},
|
|
141
|
+
journal={Nature Communications},
|
|
142
|
+
year={2022},
|
|
143
|
+
month={Apr},
|
|
144
|
+
day={19},
|
|
145
|
+
volume={13},
|
|
146
|
+
number={1},
|
|
147
|
+
pages={2064},
|
|
148
|
+
issn={2041-1723},
|
|
149
|
+
doi={10.1038/s41467-022-29632-7},
|
|
150
|
+
url={https://doi.org/10.1038/s41467-022-29632-7}
|
|
151
|
+
}
|
|
152
|
+
</pre>
|
|
153
|
+
|
|
154
|
+
## <b>Development:</b>
|
|
155
|
+
|
|
156
|
+
We warmly welcome community contributions to this project. For details on how to
|
|
157
|
+
make a contribution to ngc-learn, please see our
|
|
158
|
+
[contributing guidelines](CONTRIBUTING.md).
|
|
159
|
+
|
|
160
|
+
<b>Source Code</b>
|
|
161
|
+
You can check/pull the latest source code for this library via:
|
|
162
|
+
<pre>
|
|
163
|
+
$ git clone https://github.com/NACLab/ngc-learn.git
|
|
164
|
+
</pre>
|
|
165
|
+
|
|
166
|
+
If you are working on and developing with ngc-learn pulled from the github
|
|
167
|
+
repo, then run the following command to set up an editable install:
|
|
168
|
+
<pre>
|
|
169
|
+
$ python install -e .
|
|
170
|
+
</pre>
|
|
171
|
+
|
|
172
|
+
**Version:**<br>
|
|
173
|
+
1.0.0-Beta <!-- -Alpha -->
|
|
174
|
+
|
|
175
|
+
Author:
|
|
176
|
+
Alexander G. Ororbia II<br>
|
|
177
|
+
Director, Neural Adaptive Computing (NAC) Laboratory<br>
|
|
178
|
+
Rochester Institute of Technology, Department of Computer Science
|
|
179
|
+
|
|
180
|
+
## <b>Copyright:</b>
|
|
181
|
+
|
|
182
|
+
Copyright (C) 2021 The Neural Adaptive Computing Laboratory - All Rights Reserved<br>
|
|
183
|
+
You may use, distribute and modify this code under the
|
|
184
|
+
terms of the BSD 3-clause license.
|
|
185
|
+
|
|
186
|
+
You should have received a copy of the BSD 3-clause license with
|
|
187
|
+
this software.<br>
|
|
188
|
+
If not, please [email us](mailto:ago@cs.rit.edu)
|
ngclearn-1.0b0/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
[](https://www.python.org/downloads)[](https://opensource.org/licenses/BSD-3-Clause)[](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity)[](http://ngc-learn.readthedocs.io/en/latest/?badge=latest)[](https://zenodo.org/badge/latestdoi/483413212)
|
|
2
|
+
|
|
3
|
+
<img src="docs/images/ngc-learn-logo.png" width="300">
|
|
4
|
+
|
|
5
|
+
<b>ngc-learn</b> is a Python library for building, simulating, and analyzing
|
|
6
|
+
biomimetic systems, neurobiological agents, spiking neuronal networks,
|
|
7
|
+
predictive coding circuitry, and models that learn via biologically-plausible
|
|
8
|
+
forms of credit assignment. This simulation toolkit is built on top of JAX and is
|
|
9
|
+
distributed under the 3-Clause BSD license.
|
|
10
|
+
|
|
11
|
+
It is currently maintained by the
|
|
12
|
+
<a href="https://www.cs.rit.edu/~ago/nac_lab.html">Neural Adaptive Computing (NAC) laboratory</a>.
|
|
13
|
+
|
|
14
|
+
## <b>Documentation</b>
|
|
15
|
+
|
|
16
|
+
Official documentation, including tutorials, can be found
|
|
17
|
+
<a href="https://ngc-learn.readthedocs.io/en/latest/#">here</a>.
|
|
18
|
+
|
|
19
|
+
The official blog-post related to the source paper behind this software library
|
|
20
|
+
can be found
|
|
21
|
+
<a href="https://go.nature.com/3rgl1K8">here</a>.<br>
|
|
22
|
+
You can find the related paper <a href="https://www.nature.com/articles/s41467-022-29632-7">right here</a>, which
|
|
23
|
+
was selected to appear in the Nature <i>Neuromorphic Hardware and Computing Collection</i> in 2023 and was
|
|
24
|
+
chosen as one of the <i>Editors' Highlights for Applied Physics and Mathematics</i> in 2022.
|
|
25
|
+
|
|
26
|
+
<!--The technical report going over the theoretical underpinnings of the
|
|
27
|
+
NGC framework can be found here. TO BE RELEASED SOON. -->
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
### Dependencies
|
|
32
|
+
|
|
33
|
+
ngc-learn requires:
|
|
34
|
+
1) Python (>=3.10)
|
|
35
|
+
2) NumPy (>=1.26.0)
|
|
36
|
+
3) SciPy (>=1.7.0)
|
|
37
|
+
4) ngcsimlib (>=0.2.b1), (visit official page <a href="https://github.com/NACLab/ngc-sim-lib">here</a>)
|
|
38
|
+
5) JAX (>= 0.4.18) (to enable GPU use, make sure to install one of the CUDA variants)
|
|
39
|
+
<!--
|
|
40
|
+
5) scikit-learn (>=1.3.1) if using `ngclearn.utils.density`
|
|
41
|
+
6) matplotlib (>=3.4.3) if using `ngclearn.utils.viz`
|
|
42
|
+
6) networkx (>=2.6.3) (currently optional but required if using `ngclearn.utils.experimental.viz_utils`)
|
|
43
|
+
7) pyviz (>=0.2.0) (currently optional but required if using `ngclearn.utils.experimental.viz_utils`)
|
|
44
|
+
-->
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
ngc-learn 1.0.beta0 and later require Python 3.10 or newer as well as ngcsimlib >=0.2.b1.
|
|
48
|
+
ngc-learn's plotting capabilities (routines within `ngclearn.utils.viz`) require
|
|
49
|
+
Matplotlib (>=3.8.0) and imageio (>=2.31.5) and both plotting and density estimation
|
|
50
|
+
tools (routines within ``ngclearn.utils.density``) will require Scikit-learn (>=0.24.2).
|
|
51
|
+
Many of the tutorials will require Matplotlib (>=3.8.0), imageio (>=2.31.5), and Scikit-learn (>=0.24.2).
|
|
52
|
+
<!-- (Note: if using the `_generate_patch_set()` within the
|
|
53
|
+
image patching utilities, then Patchify will be needed).-->
|
|
54
|
+
|
|
55
|
+
### User Installation
|
|
56
|
+
|
|
57
|
+
<i>Setup</i>: The easiest way to install ngc-learn (CPU version) is through <code>pip</code>:
|
|
58
|
+
<pre>
|
|
59
|
+
$ python install ngclearn
|
|
60
|
+
</pre>
|
|
61
|
+
|
|
62
|
+
The documentation includes more detailed
|
|
63
|
+
<a href="https://ngc-learn.readthedocs.io/en/latest/installation.html">installation instructions</a>.
|
|
64
|
+
Note that this library was developed on Ubuntu 20.04 and tested on Ubuntu(s) 18.04 and 20.04.
|
|
65
|
+
|
|
66
|
+
<!--
|
|
67
|
+
<i>Setup:</i> To install ngc-learn, you can run (at the top-level of the
|
|
68
|
+
the <code>ngclearn</code> directory) the following bash command:
|
|
69
|
+
<pre>
|
|
70
|
+
$ python install .
|
|
71
|
+
</pre>
|
|
72
|
+
|
|
73
|
+
Running the above pip install will automatically install the CPU
|
|
74
|
+
version of JAX. If you want to use the GPU version instead, make sure to,
|
|
75
|
+
before running the above, to install JAX via the correct pip command
|
|
76
|
+
with the proper CUDA flags (depending on which CUDA is configured for your system)
|
|
77
|
+
as per their
|
|
78
|
+
<a href="https://jax.readthedocs.io/en/latest/installation.html">installation instructions</a>.
|
|
79
|
+
-->
|
|
80
|
+
|
|
81
|
+
<!--
|
|
82
|
+
(If you want to set up/install dependencies a priori, try running
|
|
83
|
+
`$ pip install -r requirements.txt` first before pip installing ngc-learn.)
|
|
84
|
+
-->
|
|
85
|
+
|
|
86
|
+
If the installation was successful, you should see the following if you test
|
|
87
|
+
it against your Python interpreter, i.e., run the <code>$ python</code> command
|
|
88
|
+
and complete the following sequence of steps as depicted in the screenshot below:<br>
|
|
89
|
+
<img src="docs/images/test_ngclearn_install.png" width="512">
|
|
90
|
+
|
|
91
|
+
<i>Note:</i> For access to the previous Tensorflow-2 version of ngc-learn (of
|
|
92
|
+
which we no longer support), please visit the repo for
|
|
93
|
+
<a href="https://github.com/NACLab/ngc-learn-legacy"><i>ngc-learn-legacy</i></a>.
|
|
94
|
+
|
|
95
|
+
## <b>Attribution:</b>
|
|
96
|
+
|
|
97
|
+
If you use this code in any form in your project(s), please cite its source
|
|
98
|
+
paper (as well as ngc-learn's official software citation):
|
|
99
|
+
<pre>
|
|
100
|
+
@article{Ororbia2022,
|
|
101
|
+
author={Ororbia, Alexander and Kifer, Daniel},
|
|
102
|
+
title={The neural coding framework for learning generative models},
|
|
103
|
+
journal={Nature Communications},
|
|
104
|
+
year={2022},
|
|
105
|
+
month={Apr},
|
|
106
|
+
day={19},
|
|
107
|
+
volume={13},
|
|
108
|
+
number={1},
|
|
109
|
+
pages={2064},
|
|
110
|
+
issn={2041-1723},
|
|
111
|
+
doi={10.1038/s41467-022-29632-7},
|
|
112
|
+
url={https://doi.org/10.1038/s41467-022-29632-7}
|
|
113
|
+
}
|
|
114
|
+
</pre>
|
|
115
|
+
|
|
116
|
+
## <b>Development:</b>
|
|
117
|
+
|
|
118
|
+
We warmly welcome community contributions to this project. For details on how to
|
|
119
|
+
make a contribution to ngc-learn, please see our
|
|
120
|
+
[contributing guidelines](CONTRIBUTING.md).
|
|
121
|
+
|
|
122
|
+
<b>Source Code</b>
|
|
123
|
+
You can check/pull the latest source code for this library via:
|
|
124
|
+
<pre>
|
|
125
|
+
$ git clone https://github.com/NACLab/ngc-learn.git
|
|
126
|
+
</pre>
|
|
127
|
+
|
|
128
|
+
If you are working on and developing with ngc-learn pulled from the github
|
|
129
|
+
repo, then run the following command to set up an editable install:
|
|
130
|
+
<pre>
|
|
131
|
+
$ python install -e .
|
|
132
|
+
</pre>
|
|
133
|
+
|
|
134
|
+
**Version:**<br>
|
|
135
|
+
1.0.0-Beta <!-- -Alpha -->
|
|
136
|
+
|
|
137
|
+
Author:
|
|
138
|
+
Alexander G. Ororbia II<br>
|
|
139
|
+
Director, Neural Adaptive Computing (NAC) Laboratory<br>
|
|
140
|
+
Rochester Institute of Technology, Department of Computer Science
|
|
141
|
+
|
|
142
|
+
## <b>Copyright:</b>
|
|
143
|
+
|
|
144
|
+
Copyright (C) 2021 The Neural Adaptive Computing Laboratory - All Rights Reserved<br>
|
|
145
|
+
You may use, distribute and modify this code under the
|
|
146
|
+
terms of the BSD 3-clause license.
|
|
147
|
+
|
|
148
|
+
You should have received a copy of the BSD 3-clause license with
|
|
149
|
+
this software.<br>
|
|
150
|
+
If not, please [email us](mailto:ago@cs.rit.edu)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import subprocess
|
|
3
|
+
import pkg_resources
|
|
4
|
+
from pkg_resources import get_distribution
|
|
5
|
+
#from pathlib import Path
|
|
6
|
+
#from sys import argv
|
|
7
|
+
|
|
8
|
+
__version__ = get_distribution('ngclearn').version
|
|
9
|
+
|
|
10
|
+
#required = {'ngcsimlib', 'jax', 'jaxlib'} ## list of core ngclearn dependencies
|
|
11
|
+
required = {'ngcsimlib', 'jax', 'jaxlib'}
|
|
12
|
+
installed = {pkg.key for pkg in pkg_resources.working_set}
|
|
13
|
+
missing = required - installed
|
|
14
|
+
|
|
15
|
+
for key in required:
|
|
16
|
+
if key in missing:
|
|
17
|
+
raise ImportError(str(key) + ", a core dependency of ngclearn, is not " \
|
|
18
|
+
"currently installed!")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Needed to preload is called before anything in ngclearn
|
|
22
|
+
import ngcsimlib
|
|
23
|
+
from ngcsimlib.controller import Controller
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from ngcsimlib.commands import *
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## point to rate-coded cell componet types
|
|
2
|
+
from .neurons.graded.rateCell import RateCell
|
|
3
|
+
from .neurons.graded.gaussianErrorCell import GaussianErrorCell
|
|
4
|
+
from .neurons.graded.laplacianErrorCell import LaplacianErrorCell
|
|
5
|
+
## point to standard spiking cell component types
|
|
6
|
+
from .neurons.spiking.sLIFCell import SLIFCell
|
|
7
|
+
from .neurons.spiking.LIFCell import LIFCell
|
|
8
|
+
from .neurons.spiking.quadLIFCell import QuadLIFCell
|
|
9
|
+
from .neurons.spiking.izhikevichCell import IzhikevichCell
|
|
10
|
+
## point to transformer/operater component types
|
|
11
|
+
from .other.varTrace import VarTrace
|
|
12
|
+
from .other.expKernel import ExpKernel
|
|
13
|
+
## point to input encoder component types
|
|
14
|
+
from .input_encoders.bernoulliCell import BernoulliCell
|
|
15
|
+
from .input_encoders.poissonCell import PoissonCell
|
|
16
|
+
## point to synapse component types
|
|
17
|
+
from .synapses.hebbian.hebbianSynapse import HebbianSynapse
|
|
18
|
+
from .synapses.hebbian.traceSTDPSynapse import TraceSTDPSynapse
|
|
19
|
+
from .synapses.hebbian.expSTDPSynapse import ExpSTDPSynapse
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from ngcsimlib.component import Component
|
|
2
|
+
from jax import random
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class COMPONENT_TEMPLATE(Component):
|
|
7
|
+
## Class Methods for Compartment Names
|
|
8
|
+
@classmethod
|
|
9
|
+
def DEFAULTCompartmentName(cls):
|
|
10
|
+
return 'DEFAULT'
|
|
11
|
+
|
|
12
|
+
## Bind Properties to Compartments for ease of use
|
|
13
|
+
@property
|
|
14
|
+
def DEFAULTCompartment(self):
|
|
15
|
+
return self.compartments.get(self.DEFAULTCompartmentName(), None)
|
|
16
|
+
|
|
17
|
+
@DEFAULTCompartment.setter
|
|
18
|
+
def DEFAULTCompartment(self, x):
|
|
19
|
+
if x is not None:
|
|
20
|
+
if True:
|
|
21
|
+
raise RuntimeError("")
|
|
22
|
+
self.compartments[self.DEFAULTCompartmentName()] = x
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# Define Functions
|
|
26
|
+
def __init__(self, name, key=None, useVerboseDict=False, **kwargs):
|
|
27
|
+
super().__init__(name, useVerboseDict, **kwargs)
|
|
28
|
+
|
|
29
|
+
##Random Number Set up
|
|
30
|
+
self.key = key
|
|
31
|
+
if self.key is None:
|
|
32
|
+
self.key = random.PRNGKey(time.time_ns())
|
|
33
|
+
|
|
34
|
+
##Reset to initialize stuff
|
|
35
|
+
self.reset()
|
|
36
|
+
|
|
37
|
+
def verify_connections(self):
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
def advance_state(self, **kwargs):
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
def reset(self, **kwargs):
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
def save(self, directory, **kwargs):
|
|
47
|
+
pass
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
from ngcsimlib.component import Component
|
|
2
|
+
from jax import numpy as jnp, random, jit
|
|
3
|
+
from functools import partial
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
@jit
|
|
7
|
+
def update_times(t, s, tols):
|
|
8
|
+
"""
|
|
9
|
+
Updates time-of-last-spike (tols) variable.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
t: current time (a scalar/int value)
|
|
13
|
+
|
|
14
|
+
s: binary spike vector
|
|
15
|
+
|
|
16
|
+
tols: current time-of-last-spike variable
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
updated tols variable
|
|
20
|
+
"""
|
|
21
|
+
_tols = (1. - s) * tols + (s * t)
|
|
22
|
+
return _tols
|
|
23
|
+
|
|
24
|
+
@jit
|
|
25
|
+
def sample_bernoulli(dkey, data):
|
|
26
|
+
"""
|
|
27
|
+
Samples a Bernoulli spike train on-the-fly
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
data: sensory data (vector/matrix)
|
|
31
|
+
|
|
32
|
+
dt: integration time constant
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
binary spikes
|
|
36
|
+
"""
|
|
37
|
+
s_t = random.bernoulli(dkey, p=data).astype(jnp.float32)
|
|
38
|
+
return s_t
|
|
39
|
+
|
|
40
|
+
class BernoulliCell(Component):
|
|
41
|
+
"""
|
|
42
|
+
A Bernoulli cell that produces Bernoulli-distributed spikes on-the-fly.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
name: the string name of this cell
|
|
46
|
+
|
|
47
|
+
n_units: number of cellular entities (neural population size)
|
|
48
|
+
|
|
49
|
+
key: PRNG key to control determinism of any underlying synapses
|
|
50
|
+
associated with this cell
|
|
51
|
+
|
|
52
|
+
useVerboseDict: triggers slower, verbose dictionary mode (Default: False)
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
## Class Methods for Compartment Names
|
|
56
|
+
@classmethod
|
|
57
|
+
def inputCompartmentName(cls):
|
|
58
|
+
return 'in'
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def outputCompartmentName(cls):
|
|
62
|
+
return 'out'
|
|
63
|
+
|
|
64
|
+
@classmethod
|
|
65
|
+
def timeOfLastSpikeCompartmentName(cls):
|
|
66
|
+
return 'tols'
|
|
67
|
+
|
|
68
|
+
## Bind Properties to Compartments for ease of use
|
|
69
|
+
@property
|
|
70
|
+
def inputCompartment(self):
|
|
71
|
+
return self.compartments.get(self.inputCompartmentName(), None)
|
|
72
|
+
|
|
73
|
+
@inputCompartment.setter
|
|
74
|
+
def inputCompartment(self, inp):
|
|
75
|
+
self.compartments[self.inputCompartmentName()] = inp
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def outputCompartment(self):
|
|
79
|
+
return self.compartments.get(self.outputCompartmentName(), None)
|
|
80
|
+
|
|
81
|
+
@outputCompartment.setter
|
|
82
|
+
def outputCompartment(self, out):
|
|
83
|
+
self.compartments[self.outputCompartmentName()] = out
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def timeOfLastSpike(self):
|
|
87
|
+
return self.compartments.get(self.timeOfLastSpikeCompartmentName(), None)
|
|
88
|
+
|
|
89
|
+
@timeOfLastSpike.setter
|
|
90
|
+
def timeOfLastSpike(self, t):
|
|
91
|
+
self.compartments[self.timeOfLastSpikeCompartmentName()] = t
|
|
92
|
+
|
|
93
|
+
# Define Functions
|
|
94
|
+
def __init__(self, name, n_units, key=None, useVerboseDict=False, **kwargs):
|
|
95
|
+
super().__init__(name, useVerboseDict, **kwargs)
|
|
96
|
+
|
|
97
|
+
##Random Number Set up
|
|
98
|
+
self.key = key
|
|
99
|
+
if self.key is None:
|
|
100
|
+
self.key = random.PRNGKey(time.time_ns())
|
|
101
|
+
|
|
102
|
+
##Layer Size Setup
|
|
103
|
+
self.batch_size = 1
|
|
104
|
+
self.n_units = n_units
|
|
105
|
+
self.reset()
|
|
106
|
+
|
|
107
|
+
def verify_connections(self):
|
|
108
|
+
pass
|
|
109
|
+
|
|
110
|
+
def advance_state(self, t, dt, **kwargs):
|
|
111
|
+
self.key, *subkeys = random.split(self.key, 2)
|
|
112
|
+
|
|
113
|
+
self.outputCompartment = sample_bernoulli(subkeys[0], data=self.inputCompartment)
|
|
114
|
+
#self.timeOfLastSpike = (1 - self.outputCompartment) * self.timeOfLastSpike + (self.outputCompartment * t)
|
|
115
|
+
self.timeOfLastSpike = update_times(t, self.outputCompartment, self.timeOfLastSpike)
|
|
116
|
+
|
|
117
|
+
def reset(self, **kwargs):
|
|
118
|
+
self.inputCompartment = None
|
|
119
|
+
self.outputCompartment = jnp.zeros((self.batch_size, self.n_units)) #None
|
|
120
|
+
self.timeOfLastSpike = jnp.zeros((self.batch_size, self.n_units))
|
|
121
|
+
|
|
122
|
+
def save(self, **kwargs):
|
|
123
|
+
pass
|