Giter Site home page Giter Site logo

nengo-gyrus's Introduction

Recursively generate large-scale Nengo models using NumPy semantics.

Recursively generate large-scale Nengo models using NumPy semantics.

Quick Start

pip install git+https://github.com/nengo-labs/nengo-gyrus

An example of computing the square of a two-dimensional vector with Gyrus:

import gyrus
import matplotlib.pyplot as plt
import numpy as np

u = gyrus.stimuli([np.cos, np.sin])
x = (u ** 2).filter(0.01)
y = np.asarray(x.run(np.pi))  # shape: (fold, time, size_out)

plt.figure()
plt.plot(y.squeeze(axis=-1).T)
plt.xlabel("Time-step")
plt.show()
Computing the square of a two-dimensional vector with Gyrus.

This code is automagically converted to Nengo and implemented via two spiking LIF ensembles and a lowpass synapse.

Gyrus supports many common NumPy 'ufuncs', array functions, and numeric Python operators. Thus, code can be written in a functional style using N-D arrays and then realized as a Nengo neural network. This enables algorithms to be written in NumPy and then compiled onto Nengo's supported backends (e.g., GPUs, microcontrollers, neuromorphic hardware, and other neural network accelerators).

Documentation

Check out and render the Jupyter notebooks located in docs/examples.

The gyrus_overview notebook is currently the best starting point to learn the Gyrus API and see a variety of examples.

Support

Tested against nengo>=3.0.0 and requires numpy>=1.17.

This project is currently pre-alpha. Pull requests are welcome, as are breaking (i.e., reverse-incompatible) changes.

If something doesn't work quite as you thought it should, or if you have ideas for improvements, please feel free to open up a GitHub issue or post on the Nengo Forum.

nengo-gyrus's People

Contributors

arvoelke avatar hunse avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nengo-gyrus's Issues

Tests fail for Numpy < 1.19

I've tried running the tests with Numpy 1.17.0 and 1.18.5, and in both cases I get a Fatal Python error: Cannot recover from stack overflow on test_auto.py::test_config_downstream_precedence, followed by Python completely crashing. When I switch to 1.19.0, everything passes.

Here's the repeated part of the stack trace that is obviously getting into a loop:

  File "/home/eric/venv/full3/lib/python3.6/site-packages/numpy/core/_asarray.py", line 85 in asarray
  File "/data/eric/workspace/nengo-gyrus/gyrus/base.py", line 171 in array
  File "/data/eric/workspace/nengo-gyrus/gyrus/utils.py", line 15 in wrapper
  File "/data/eric/workspace/nengo-gyrus/gyrus/base.py", line 204 in __getitem__

The easiest resolution would be to just require Numpy >= 1.19. One downside is that TensorFlow still requires Numpy < 1.19 (at least nominally, though I'm pretty sure it generally runs OK with 1.19).

Validate the integrand in integrate_fold

Minimal example:

u = gyrus.stimuli(np.zeros(2))
u.integrate_fold(integrand=lambda x: x[0])
AttributeError: 'Slice' object has no attribute 'flatten'

Because Gyrus expects the integrand to return a fold (or, more generally, an ndarray with the same shape as u) and not a scalar operator.

Investigate Nengo graph rewrite optimizations

The final spiking matrix inversion example currently takes ~27 seconds with Nengo optimize=True, ~52 seconds with Nengo optimize=False, and ~32-38 seconds with NengoDL. The model is really just 500 recurrently connected neurons being simulated for 2.5 seconds (2,500 time-steps), although it is being built up using lots of passthrough nodes and a separate ensemble for each neuron. This is likely causing issues for both Nengo and TensorFlow that could be solved by some larger model rewrite optimizations in Gyrus before handing off the model to the backend, or by extending the Nengo core optimizer.

More context: https://forum.nengo.ai/t/gyrus-running-time/1584/5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.