Nengo

Nengo is a software package for neuromorphic computation, developed by Applied Brain Research, which is a spin-off from the University of Waterloo. Includes nengo and nengo gui.

Nengo is used to build SPAUN, "the first simulated brain that is capable of performing tasks" (Tutorial 0).

In the GUI, you are not allowed to define a Simulator object yourself, as the GUI takes care of that. The GUI also has its own visualisations so do not use matplotlib in this scenario.

Also see 202010071335-Nengo_on_FPGA.md

First Skeleton:

import nengo

model = nengo.Network()
with model:
    stim = nengo.Node(0)
    ens = nengo.Ensemble(n_neurons=10, dimensions=1, seed=5)
    nengo.Connection(stim, ens)

Top graph shows input signal, middle neurotransmitter releases/ neuronal response, and the bottom graph the signal as decoded from the neuronal outputs.

Connections ensembles and computing

import nengo

model = nengo.Network()
with model:
    stim = nengo.Node(0)
    a = nengo.Ensemble(n_neurons=50, dimensions=1)
    nengo.Connection(stim, a)

    b = nengo.Ensemble(n_neurons=50, dimensions=1)

    def compute_this(x):
        return 1 if x>0 else 0

    nengo.Connection(a, b, synapse=0.01, function=compute_this)

Make ensemble b take its input from the output of ensemble a. You can just pass the input, but you can also provide a computation to the connection to specify the target relation between the two ensembles.

The synapse parameter indicates the amount of time for the effects of a single spike to wear off.

A realistic range is [0.002-0.2]. Default value is 0.005, which is a fairly fast connection.

Summing inputs

import nengo

model = nengo.Network()
with model:
    stim_a = nengo.Node(0)
    a = nengo.Ensemble(n_neurons=50, dimensions=1)
    nengo.Connection(stim_a, a)

    stim_b = nengo.Node(0)
    b = nengo.Ensemble(n_neurons=50, dimensions=1)
    nengo.Connection(stim_b, b)

    c = nengo.Ensemble(n_neurons=50, dimensions=1, radius=1)
    nengo.Connection(a, c)
    nengo.Connection(b, c)

Ensemble c takes inputs from both a and b, effectively summing them. However, it currently cannot actually sum properly because the sum is outside of its radius. See we should update that radius to 2. Additionally, we need to manually adjust the scale of the output graph (right click).

Dimensionality and combining information

An ensemble can represent multiple values at once. If an ensemble is supposed to represent 3D coordinates, it has dimension 3.

These values will be kept apart, so we can then also connect the separate values represented in an ensemble with another specific value in another.

Slicing is fully supported.

This is different from addition because then we combine two outputs into one value. Here we pipe them into two separate values encoded by ensemble c.

import nengo

model = nengo.Network()
with model:
    stim_a = nengo.Node(0)
    a = nengo.Ensemble(n_neurons=50, dimensions=1)
    nengo.Connection(stim_a, a)

    stim_b = nengo.Node(0)
    b = nengo.Ensemble(n_neurons=50, dimensions=1)
    nengo.Connection(stim_b, b)

    c = nengo.Ensemble(n_neurons=200, dimensions=2)
    nengo.Connection(a, c[0])
    nengo.Connection(b, c[1])

This example does multiplication. Important detail is that ensemble c has a radius of 1.5/sqrt(2) to make sure we increase the radius a bit.

REVIEW: why sqrt(2)?

Scalars

For scalar transforms, you can define a function, but there's a built-in shortcut.

1D: nengo.Connection(a, b2, transform=-0.5)

3D: nengo.Connection(c, d2, transform=[2, -1, -1](2,_-1,_-1.md))

Docs

Processes

Learning a communication signal

Learning to compute a product