To install Nengo, we recommend using
pip install nengo
pip will do its best to install
all of Nengo’s requirements when it installs Nengo.
However, if anything goes wrong during this process,
you can install Nengo’s requirements manually
pip install nengo again.
Nengo’s only required dependency is NumPy, and we recommend that you install it first. The best way to install NumPy depends on several factors, such as your operating system. Briefly, what we have found to work best on each operating system is:
Linux: Use a package manager or install from source
For more options, see SciPy.org’s installation page. For our recommended options, read on.
If you’re new to Python and just want to get up and running,
Anaconda is the best way to get started.
Anaconda provides an all-in-one solution
that will install Python, NumPy,
and other optional Nengo dependencies.
It works on all operating systems (Windows, Mac, Linux)
and does not require administrator privileges.
It includes GUI tools,
as well as a robust command line tool,
for managing your Python installation.
If you are comfortable with the command line, operating systems other than Windows have a package manager that can install Python and NumPy.
Mac OS X: Homebrew has excellent Python support. After installing Homebrew,
brew install pythonand
pip install numpy.
Linux: Linux distributions come with a package manager capable of installing Python and NumPy. In Debian, Ubuntu, and other distributions with
sudo apt-get install python-numpy. In Fedora and others distributions with
sudo yum install python-numpy. For other package managers, try searching the package list for
Installing other packages¶
While NumPy is the only hard dependency,
some optional Nengo features require other packages.
These can be installed either through
Anaconda, a package manager, or through
Python’s own package manager,
Additional decoder solvers and other speedups require SciPy and scikit-learn.
Running the test suite requires pytest, Matplotlib, and Jupyter.
Building the documentation requires Sphinx, NumPyDoc and guzzle_sphinx_theme.
These additional dependencies can be installed
pip when installing Nengo.
pip install nengo[optional] # Additional solvers and speedups pip install nengo[docs] # For building docs pip install nengo[tests] # For running the test suite pip install nengo[all] # All of the above
Everything in a Nengo model is contained within a
nengo.Network. To create a new
import nengo net = nengo.Network()
Creating Nengo objects¶
A Nengo object is a part of your model that represents information.
When creating a new object, you must place it within a
block in order to inform Nengo which network your object
should be placed in.
There are two objects that make up a basic Nengo model.
nengo.Ensemble is a group of neurons that represents
information in the form of real valued numbers.
with net: my_ensemble = nengo.Ensemble(n_neurons=40, dimensions=1)
In this case,
my_ensemble is made up of
40 neurons (by default, Nengo uses leaky integrate-and-fire neurons)
and it is representing a one dimensional signal.
In other words, this ensemble represents a single number.
In order to provide input to this ensemble
(to emulate some signal that exists in nature, for example)
we create a
with net: my_node = nengo.Node(output=0.5)
In this case,
my_node emits the number 0.5.
In most cases, however, we want more dynamic information.
We can make a
nengo.Node using a function as output
instead of a number.
with net: sin_node = nengo.Node(output=np.sin)
This node will represent a sine wave.
Connecting Nengo objects¶
We can connect nodes to ensembles in order to represent that information in the activity a group of neurons.
with net: nengo.Connection(my_node, my_ensemble)
my_ensemble will now represent
0.5 in its population of 40 neurons.
Ensembles can also be connected to other models. When the dimensionality of the objects being connected are different, we can use Python’s slice syntax to route information from one node or ensemble to another. For example:
with net: two_d_ensemble = nengo.Ensemble(n_neurons=80, dimensions=2) nengo.Connection(sin_node, two_d_ensemble) nengo.Connection(my_ensemble, two_d_ensemble)
This creates a new ensemble that represents
two real-valued signals.
its first dimension now represents a sine wave.
Its second dimensions now represents the same
When creating connections, we can specify a function that will be computed across the connection.
with net: square = nengo.Ensemble(n_neurons=40, dimensions=1) nengo.Connection(my_ensemble, square, function=np.square)
Functions can be computed over multiple dimensions, as well.
def product(x): return x * x with net: product_ensemble = nengo.Ensemble(n_neurons=40, dimensions=1) nengo.Connection(two_d_ensemble, product_ensemble, function=product)
Probing Nengo objects¶
Once you have defined the objects in your model and how they’re connected, you can decide what data you want to collect by probing those objects.
If we wanted to collect data from our 2D Ensemble and the Product of those two dimensions:
with net: two_d_probe = nengo.Probe(two_d_ensemble, synapse=0.01) product_probe = nengo.Probe(product_ensemble, synapse=0.01)
synapse defines the time constant
on a causal low-pass filter,
which approximates a simple synapse model.
The output of ensembles of spiking neurons
can be very noisy, so a filter is recommended.
Running an experiment¶
Once a model has been constructed and we have probed certain objects, we can run it to collect data.
To run a model, we must first build a simulator based on the model we’ve defined.
sim = nengo.Simulator(net)
We can then run that simulator. For example, to run our model for five seconds:
Once a simulation has been run at least once (it can be run for additional time if desired) the data collected can be accessed for analysis or visualization.
For more details on these objects, see the API documentation.
If you’re wondering how this works and you’re not familiar with the Neural Engineering Framework, we recommend reading this technical overview.
If you have some understanding of the NEF already, or just want to dive in headfirst, check out our extensive set of examples.
If you want to see the real capabilities of Nengo, see our publications created with the NEF and Nengo.