-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use new mandatory build.os env variable for RTD * move examples to docs and make executable * shorten sphinx config and add myst_nb to decode notebooks * jupyter-book not needed for docs requirements * Minor README update * add NIR symbol pngs * add myst-nb as docs requirement * modify example titles * update primitives in docs * add sphinx autoapi * minor text edits in document titles * add sphinx-autoapi to docs requirements * fix autoapi upstream bug by pinning astroid dep * add html_title to docs * Change logo in sidebar * Corrected ruff github ci command --------- Co-authored-by: Jens E. Pedersen <[email protected]>
- Loading branch information
Showing
40 changed files
with
597 additions
and
472 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
sphinx==5.0.2 | ||
sphinx-book-theme | ||
myst-parser | ||
myst_nb | ||
numpy | ||
h5py | ||
sphinx_external_toc | ||
sphinxcontrib-mermaid | ||
jupyter-book | ||
astroid~=2.15 # https://github.com/readthedocs/sphinx-autoapi/issues/407 | ||
sphinx-autoapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Contributing to NIR | ||
# Contributing | ||
|
||
## Developer guide: Getting started | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Lava\n", | ||
"\n", | ||
"... coming soon" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Nengo\n", | ||
"\n", | ||
"[Nengo](nengo.ai) is a Python package for building, testing, and deploying neural networks.\n", | ||
"The examples below shows how to import and export from Nengo to NIR and vice-versa.\n", | ||
"\n", | ||
"Examples:\n", | ||
"* Lorentz oscillator: [nir-lorentz.py](https://github.com/neuromorphs/nir/tree/main/example/nengo/nir-lorentz.py)\n", | ||
" * This script creates a Nengo model that simulates the Lorentz oscillator, maps it to NIR, and then back again into Nengo\n", | ||
"* Leaky integrate-and-fire (LIF) tests [nir-test.py](https://github.com/neuromorphs/nir/tree/main/example/nengo/nir-test.py)\n", | ||
" * Creates a NIR model for an Affine map and LIF population and map it into Nengo\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "plaintext" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import nengo\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"import nir\n", | ||
"\n", | ||
"n = nir.NIRGraph(\n", | ||
" nodes=[\n", | ||
" nir.Input(shape=np.array([3])),\n", | ||
" nir.Affine(weight=np.array([[8, 2, 10], [14, 3, 14]]).T, bias=np.array([1, 2])),\n", | ||
" nir.LIF(\n", | ||
" tau=np.array([1] * 2),\n", | ||
" r=np.array([1] * 2),\n", | ||
" v_leak=np.array([0] * 2),\n", | ||
" v_threshold=np.array([1] * 2),\n", | ||
" ),\n", | ||
" nir.Output(shape=np.array([3])),\n", | ||
" ],\n", | ||
" edges=[(0, 1), (1, 2), (2, 3)],\n", | ||
")\n", | ||
"\n", | ||
"\n", | ||
"def nir_to_nengo(n, swap_linear_order=False):\n", | ||
" nengo_map = []\n", | ||
"\n", | ||
" model = nengo.Network()\n", | ||
" with model:\n", | ||
" filters = {}\n", | ||
" for i, obj in enumerate(n.nodes):\n", | ||
" if isinstance(obj, nir.Input):\n", | ||
" node = nengo.Node(np.zeros(obj.shape), label=f\"Input {i} {obj.shape}\")\n", | ||
" nengo_map.append(node)\n", | ||
" elif isinstance(obj, nir.LIF):\n", | ||
" N = obj.tau.flatten().shape[0]\n", | ||
" ens = nengo.Ensemble(\n", | ||
" n_neurons=N,\n", | ||
" dimensions=1,\n", | ||
" label=f\"LIF {i}\",\n", | ||
" neuron_type=nengo.RegularSpiking(\n", | ||
" nengo.LIFRate(tau_rc=obj.tau[0], tau_ref=0)\n", | ||
" ),\n", | ||
" # neuron_type=nengo.LIF(tau_rc=obj.tau[0], tau_ref=0),\n", | ||
" gain=np.ones(N),\n", | ||
" bias=np.zeros(N),\n", | ||
" )\n", | ||
" nengo_map.append(ens.neurons)\n", | ||
" elif isinstance(obj, nir.LI):\n", | ||
" filt = nengo.Node(\n", | ||
" lambda t, x: x,\n", | ||
" size_in=obj.tau.flatten().shape[0],\n", | ||
" label=f\"LI {i} {obj.tau.shape}\",\n", | ||
" )\n", | ||
" filters[filt] = nengo.synapses.Lowpass(obj.tau[0])\n", | ||
" nengo_map.append(filt)\n", | ||
" elif isinstance(obj, nir.Affine):\n", | ||
" weights = obj.weight\n", | ||
" if swap_linear_order:\n", | ||
" weights = weights.T\n", | ||
" w = nengo.Node(\n", | ||
" lambda t, x, obj=obj: weights @ x + obj.bias,\n", | ||
" size_in=weights.shape[1],\n", | ||
" size_out=weights.shape[0],\n", | ||
" label=f\"({weights.shape[0]}x{weights.shape[1]})\",\n", | ||
" )\n", | ||
" nengo_map.append(w)\n", | ||
" elif isinstance(obj, nir.Output):\n", | ||
" nengo_map.append(\n", | ||
" None\n", | ||
" ) # because NIR spec doesn't tell me the size, I can't create this yet\n", | ||
" else:\n", | ||
" raise Exception(f\"Unknown NIR object: {obj}\")\n", | ||
" for pre, post in n.edges:\n", | ||
" if nengo_map[post] is None:\n", | ||
" output = nengo.Node(\n", | ||
" lambda t, x: x,\n", | ||
" size_in=nengo_map[pre].size_out,\n", | ||
" label=f\"Output {post}\",\n", | ||
" )\n", | ||
" nengo_map[post] = output\n", | ||
" synapse = filters.get(nengo_map[post], None)\n", | ||
"\n", | ||
" if nengo_map[pre].size_out != nengo_map[post].size_in:\n", | ||
" print(\"Error\")\n", | ||
" print(\"pre\", nengo_map[pre])\n", | ||
" print(\"post\", nengo_map[post])\n", | ||
" 1 / 0\n", | ||
"\n", | ||
" else:\n", | ||
" nengo.Connection(nengo_map[pre], nengo_map[post], synapse=synapse)\n", | ||
"\n", | ||
" return model\n", | ||
"\n", | ||
"\n", | ||
"model = nir_to_nengo(n, swap_linear_order=True)\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
File renamed without changes.
Oops, something went wrong.