Visualisation tool for the Neuromorphic Intermediate Representation
Project description
Neuromorphic Intermediate Representation Visualisation Tool
Turn your NIR definitions into a nice graph, the original publication serving as a template.
Customise your node colour preferences in style.yml, and quickly generate graphs from your neuromorphic networks.
This work is in progress.
Running Example (Jupyter Notebook)
By running the following code (from a notebook),
import nir
import nirviz
import numpy as np
a = np.random.randn(2)
ir = nir.NIRGraph(
nodes={
"input": nir.Input(input_type=np.array([2])),
"affine1": nir.Affine(weight=np.zeros((2,2)), bias=False),
"cu1": nir.CubaLIF(tau_mem=a, tau_syn=a, r=a, v_leak=a, v_threshold=a, v_reset=a),
"affine_rec": nir.Affine(weight=np.zeros((2,2)), bias=False),
"affine2": nir.Affine(weight=np.zeros((2,2)), bias=False),
"cu2": nir.CubaLIF(tau_mem=a, tau_syn=a, r=a, v_leak=a, v_threshold=a, v_reset=a),
"output": nir.Output(output_type=np.array([2]))
},
edges=[("input", "affine1"), ("affine1", "cu1"), ("affine_rec", "cu1"), ("cu1", "affine_rec"), ("cu1", "affine2"), ("affine2", "cu2"), ("cu2", "output")])
viz = nirviz.visualize(ir)
viz.show()
You would get the following visualisation
Similar to Figure 3 of the publication.
Running example (CLI)
To convert a saved NIR graph (e.g. srnn.nir) to a PNG or SVG, you can use one of the following commands:
python -m nirviz srnn.nir # SVG -> stdout
python -m nirviz srnn.nir img/srnn.png # PNG -> file
python -m nirviz srnn.nir img/srnn.svg # SVG -> file
Customising the style
You can customise the style you see via the style file.
Style file location
The style file is defined in YAML. You can find the default location by running:
import nirviz
print(f"nirviz style file location: {nirviz.visualize.default_style_file()}")
or by passing your own style.yml:
import nirviz
viz = nirviz.visualize(nir_graph, style_file="style.yml")
viz.show()
python -m nirviz --yaml './style.yml' srnn.nir
Style file format
The format currently only supports setting node attributes. The node attributes correspond to Graphviz node attributes. An example file would contain:
node-categories:
category-name: # User defined
patterns: ["Affine", "IF"]
attributes:
# Corresponds to node attributes of graphviz
# https://graphviz.org/docs/nodes/
color: "red"
style: "filled"
shape: "box"
Which would paint all "Affine" and "IF" NIR nodes red.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nirviz-0.1.4.tar.gz.
File metadata
- Download URL: nirviz-0.1.4.tar.gz
- Upload date:
- Size: 72.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a27c01bd4843612461e03dca7e620fab7d46af8a5918f36bc8d7fdb3d62174a
|
|
| MD5 |
d32ad71d9f680d09ed34534a7526c93c
|
|
| BLAKE2b-256 |
956bdc08ccbaa140c0b8347849c3343308f0c53985e2cd88e15fbe41dc20b361
|
Provenance
The following attestation bundles were made for nirviz-0.1.4.tar.gz:
Publisher:
pypi.yml on open-neuromorphic/nirviz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nirviz-0.1.4.tar.gz -
Subject digest:
8a27c01bd4843612461e03dca7e620fab7d46af8a5918f36bc8d7fdb3d62174a - Sigstore transparency entry: 464837161
- Sigstore integration time:
-
Permalink:
open-neuromorphic/nirviz@d0500bf5266acaa3f4c49ee378a35aacd2206d5a -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/open-neuromorphic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@d0500bf5266acaa3f4c49ee378a35aacd2206d5a -
Trigger Event:
release
-
Statement type:
File details
Details for the file nirviz-0.1.4-py3-none-any.whl.
File metadata
- Download URL: nirviz-0.1.4-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e098e99fc506658b043eb16ecb244aa92895693fe23743c6f425d8f72521ce18
|
|
| MD5 |
26cb214e48aa2b470c7c5f30dcec5609
|
|
| BLAKE2b-256 |
5bae67c3835c5e46bee2b692f1331c2099d66cde09e8bb07c18c6d9e9e8f6291
|
Provenance
The following attestation bundles were made for nirviz-0.1.4-py3-none-any.whl:
Publisher:
pypi.yml on open-neuromorphic/nirviz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nirviz-0.1.4-py3-none-any.whl -
Subject digest:
e098e99fc506658b043eb16ecb244aa92895693fe23743c6f425d8f72521ce18 - Sigstore transparency entry: 464837201
- Sigstore integration time:
-
Permalink:
open-neuromorphic/nirviz@d0500bf5266acaa3f4c49ee378a35aacd2206d5a -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/open-neuromorphic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@d0500bf5266acaa3f4c49ee378a35aacd2206d5a -
Trigger Event:
release
-
Statement type: