Training loop using Nengo network


so far I have been using for training my models, but my new task requires me to use preloaded batches.
I was wondering if there is a good way to explicitly train on batches like in this post:

Thanks :slight_smile:

Hi Julian and welcome to the forum!

The keras example you reference is creating a custom training loop, which you probably don’t need to do.

NengoDL is setup to use batching by default, you should be able to simply set the batch size for the simulator object (nengo_dl.Simulator.minibatch_size). Take a look at the Batch Processing section of the docs.

If you want more control over the dataset, you could also try creating a data generator to provide the training inputs. For example, Tensorflow has and there is more information about inputs and a brief example of this in the docs:

with nengo.Network() as net:
    a = nengo.Node([0], label="a")
    p = nengo.Probe(a, label="p")

with nengo_dl.Simulator(net) as sim:
    dataset =
        ({"a": tf.ones((50, 10, 1)),
          "n_steps": tf.ones((50, 1), dtype=tf.int32) * 10},
         {"p": tf.ones((50, 10, 1))})


Keras also has methods for creating data generators if you prefer to integrate that instead, take a look at this post about keras data generators

I hope this helps!

1 Like