Modify neuron state during simulation

Hi,
I implemented a network in nengo to do image classification. Image is represented by number of spikes in a given time window, for example, 10 ms. In other words, every 10 ms the input image is changed.
But now the problem is that after the input image is changed, neurons accumulated non-zero voltage due to the previous input, which lowers the accuracy. Is there any way to set the voltage to 0 periodically during simulation?
Thank you!

I’m assuming you’re using the nengo.LIF() neuron model? One way of doing this would be to “blast” the neurons with inhibition each time you present a new image. A large momentary influx of negative current will rapidly clip the voltage vector back to its minimum of 0. Something like:

nengo.Connection(shutoff_gate, ens.neurons,
                 transform=-100*np.ones((ens.n_neurons, 1)), synapse=None)

where ens is the ensemble that you want to reset back to zero voltage. Then you’ll need to define shutoff_gate to be some custom Node with your own function that is 1 if and only if you’re inside the time-step when the input is changed, and 0 otherwise. Let us know how this goes.

2 Likes

It also just occurred to me that there may be more going on than the state of the non-zero voltage holding memory. The synapses may be playing a more important role. The synapse also maintains some state that is carried over across image presentations, and I would expect the impact there to be considerably larger, since they are essentially “remembering” the values passed between populations. However I’m not sure of a way to reset the state of all your synapses mid-simulation. There might be a hacky way to do it… but this goes against the grain of Nengo design, as its synapses are continuously integrating inputs over some fixed time-scale, without any nonlinear resetting/clipping.

The code snippets here may or may not be useful, as they were being used 3 years ago on a much earlier version of Nengo: https://github.com/nengo/nengo/issues/888

1 Like

Thanks for reply.
I implemenetd a custom process as you suggested. The reset is successful.
Essestially the synapse is filer, so it has states. Even the voltage can be reset, the synapse state can’t be reset. But I find that nengo allowe the synapse type to be none, then the connection is just simple direct connection.
I tested with none type synapse, and it works correctly as i expected.

I shared my implementation here, in case someone also has this requirement.

#define a custom function
class reset_process(nengo.Process):
    def make_step(self, shape_in, shape_out, dt, rng):
        timer = np.zeros(1)
        def step(t):
            timer[0] = timer[0] + 1
            if timer[0] == 100: # reset every 100 ticks
                timer[0] = 0
                return 1
            else:
                return 0     
        return step

with model:
    #...    
    # process to reset neurons
    reset_process  = nengo.Node(reset_process())
    nengo.Connection(reset_process, ens.neurons,
                     transform=-100*np.ones((ens.n_neurons, 1)), synapse=None)
    #...