User guide

Running models

There are two ways to run Nengo models. They can be run either with the Nengo GUI, or they can be run with a Python interpreter.

With Nengo GUI

The Nengo GUI is a web-based interface for designing and running Nengo models. To start the GUI, open a terminal and run the nengo command.

To access the GUI, you use a web browser like Google Chrome or Firefox. You should see a depiction of the network on the left panel, and a code editor on the right panel.

http://appliedbrainresearch.com/img/gui-03.gif

The network illustration on the left panel is interactive. You can drag to move the network objects, scroll with the mouse to zoom in and out, and right-click on objects to display plots that will update in real time as the model simulates (see the GUI documentation for more details).

The code editor on the right panel shows the Python code defining the Nengo model. While you can write any Python code in this editor, we add a few additional constraints to ensure the GUI runs smoothly:

  • Your top-level network must be called model.
  • You cannot construct a Simulator object, as the GUI makes its own Simulator under the hood.
  • You cannot show plots created with Matplotlib, as the GUI has its own set of visualizations.

To access a series of tutorials that introduce you to the GUI and to the basics of building models with Nengo, click on the folder icon at the top-left of the GUI, select “built-in examples”, and then “tutorial”.

If you see a warning that says something like Warning: Simulators cannot be manually run inside nengo_gui, then you are likely running a model that is designed to run with a Python interpreter (see below for details). If the model you are trying to run is a Nengo example, then it’s likely that a similar example exists within the built-in examples accessible through the folder icon at the top-left of the GUI.

With a Python interpreter

The Nengo core is written in Python. In order to install Nengo, you likely also installed a Python distribution, whether it be through a package manager provided by your operating system, through Anaconda, or by some other means. You can use Nengo through any Python interpreter, like any other Python package.

All Python distributions come with an interpreter that you can usually run through a terminal by typing in python and hitting enter. You should see a prompt that looks like this:

$ python
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

You can then import nengo and start building models.

>>> import nengo
>>> model = nengo.Network("My model")

The examples included with Nengo core can be downloaded as Python scripts (text files that have the .py extension). These scripts can be run from a terminal. For example, after downloading single_neuron.py, you can run it like this:

$ python single_neuron.py

If all goes well, you will see a plot generated by Matplotlib. Since Nengo is a normal Python package, it interacts well with other Scientific Python packages.

The Jupyter notebook provides another way to run Python scripts. We also provide Nengo core examples as Jupyter notebooks because you can see plots in the same interface as the code. Jupyter notebooks are also text files, but have the extension .ipynb. These are run through the Jupyter notebook. For example, after downloading single_neuron.ipynb, you can start the notebook like this:

$ jupyter notebook

and then click on single_neuron.ipynb to run the example.

To access a series of tutorials that use Nengo with a Python interpreter, see the Nengo documentation.

Learning more

Reference

The following links are useful to refer to when building models.