nengo / nengo-gui

Nengo interactive visualizer
Other
97 stars 38 forks source link

Add backend to InlineGUI constructor #1008

Closed bmorcos closed 5 years ago

bmorcos commented 5 years ago

Motivation and context:

I was making a notebook for NengoFPGA that needed the embedded GUI and realized the constrcutor does not allow you to set the backend. See #1005 for details.

How has this been tested?

Tested a simple network in a notebook. I tried setting various backends to ensure it was correctly set in page_settings and I ran a network successfully using the nengo_fpga backend.

eg.

import numpy as np
import nengo
from nengo_gui.jupyter import InlineGUI
from nengo_fpga.networks import FpgaPesEnsembleNetwork

with nengo.Network() as model:
    input_node = nengo.Node(lambda x: np.sin(x*10), label='input signal')

    # FPGA neural ensemble
    pes_ens = FpgaPesEnsembleNetwork(
        'de1', n_neurons=100, dimensions=1, learning_rate=0,
        label='ensemble')

    nengo.Connection(input_node, pes_ens.input)

    # Reference value passthrough node
    ref_node = nengo.Node(size_in=1)
    nengo.Connection(input_node, ref_node)

viz = InlineGUI(model, backend='nengo_fpga')  # Create GUI object
print(viz.server.server.page_settings.backend)  # Check backend that was set
viz  # Launch GUI and check simulation

How long should this take to review?

Where should a reviewer start?

Create a simple test network in a notebook and test various backends.

Types of changes:

Checklist:

tcstewar commented 5 years ago

Nice! thank you for putting this together! That seems like a handy thing to have easy access to.