Problem with passing data for batch processing using nengo DL


it seems like the nengo DL simulator cannot find the Node(s) I want to assign data to so that i can use batch processing.

here is a shortened overview of the relevant aspects of the code:

def create_model(seed=None):

global model

model = spa.SPA(seed=seed)
with model:


if sim_to_run == 2:


sim = nengo_dl.Simulator(network=model, minibatch_size=minibatch_size, seed=subj, device=device, progress_bar=False)

input_data_first, input_data_second, input_data_reactivate = get_data(minibatch_size,4600,probelist)

sim.run_steps(4600, data = {inputNode_first: input_data_first, inputNode_second: input_data_second, reactivate: input_data_reactivate})

I hope this is enough information, if not let me know.

The error message I get says: NameError: name 'inputNode_first' is not defined

I tried it by using: 'inputNode_first' (passing it as a string like I normally would for the key of a dictionary) but then I get an error message saying:
"Data objects must be Nodes or Probes, not %s" % d, "data" nengo.exceptions.ValidationError: data: Data objects must be Nodes or Probes, not inputNode_first

I also tried using model.inputNode_first but this also did not work and gave me the error message:
AttributeError: 'SPA' object has no attribute 'inputNode_first'

Could somebody explain to me what is going wrong?

I am using: Nengo 2.8.0, Nengo DL 2.2.2, python 3.6.7


This error message is cropping up because you defined inputNode_first inside a function, so later on outside of the function you don’t have access to it. Even though you declare model as a global, you haven’t attached inputNode_first to model, which is why you can’t access it as model.inputNode_first.

In general, it’s recommended to return variables from functions using return var1, var2, etc instead of declaring global variable. I’ve reworked your example below so that it runs:

import nengo_dl
import numpy as np

def create_model(seed=None):
    model = nengo.Network()
    with model:

        model.inputNode_first = nengo.Node(np.zeros(128 * 128))
        model.inputNode_second = nengo.Node(np.zeros(128 * 128))
        model.reactivate = nengo.Node(np.zeros(10))
        model.probe_reactivate = nengo.Probe(model.reactivate)

    return model

subj = 0
model = create_model(seed=subj)

sim = nengo_dl.Simulator(

n_timesteps = 1
input_data_first = input_data_second = np.ones((1, n_timesteps, 128**2))
input_data_reactivate = np.ones((1, n_timesteps, 10))

        model.inputNode_first: input_data_first,
        model.inputNode_second: input_data_second,
        model.reactivate: input_data_reactivate,
print('probe_reactivate: ',[model.probe_reactivate])

Note that I changed it to model = nengo.Network() and took out a few other parameters, these were just simplifications on my part to get this demo script running, this will work with any functioning Nengo network. Hope this helps!