human
I am working on the file "SYDE 556 Lecture 9 Action Selection.ipynb".
The first task is:
Now we only influence other Actions when we have a positive value
Note: Is there a more neurally efficient way to do this?

Much better
Selects one action reliably
But still gives values smaller than 1.0 for the output a lot
Can we fix that?
What if we adjust e?
Can you write Python code for it?
assistant
#Here is Python code to fix that.

%pylab inline
import nengo

def stimulus(t):
    if t<.3:
        return [.5,.4]
    elif .3<t<.5:
        return [.4,.5]
    else:
        return [0,0] 
    
model = nengo.Network('Selection')

with model:
    stim = nengo.Node(stimulus)
        
    s = nengo.Ensemble(200, dimensions=2)
    Qs = nengo.networks.EnsembleArray(50, n_ensembles=4)
    Action = nengo.networks.EnsembleArray(50, n_ensembles=4)
    
    nengo.Connection(s, Qs.input, transform=[[1,0],[-1,0],[0,1],[0,-1]])
    nengo.Connection(Qs.output, Action.input)
    
    e = .5
    i = -1

    recur = [[e, i, i, i], [i, e, i, i], [i, i, e, i], [i, i, i, e]]    

    # Let's force the feedback connection to only consider positive values
    def positive(x):
        if x[0]<0: return [0]
        else: return x
    pos = Action.add_output('positive', positive)
    
    nengo.Connection(pos, Action.input, transform=recur)
    nengo.Connection(stim, s)
    
    model.config[nengo.Probe].synapse = nengo.Lowpass(0.01)
    qs_p = nengo.Probe(Qs.output)
    action_p = nengo.Probe(Action.output)
    s_p = nengo.Probe(s)

from nengo_gui.ipython import IPythonViz
IPythonViz(model, "configs/action_selection.py.cfg")

sim = nengo.Simulator(model)
sim.run(1.)

t = sim.trange()

plot(t, sim.data[s_p], label="state")
legend(loc='best')

figure()
plot(t, sim.data[qs_p], label='Qs')
legend(loc='best')

figure()
plot(t, sim.data[action_p], label='Action')
legend(loc='best');