%pylab inline
//anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment. warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
Populating the interactive namespace from numpy and matplotlib
%pylab inline
import nengo
from nengo.utils.ensemble import tuning_curves
model = nengo.Network()
with model:
a = nengo.Ensemble(100, dimensions=1, radius=3)
conn = nengo.Connection(a,a)
sim = nengo.Simulator(model)
x, A = tuning_curves(a, sim)
plot(x,A);
d = sim.data[conn].weights.T
xhat = numpy.dot(A, d)
figure()
plot(xhat)
//anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment. warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
Populating the interactive namespace from numpy and matplotlib Building finished in 0:00:01.
[<matplotlib.lines.Line2D at 0x10eae71d0>]
%pylab inline
Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['rate', 'e', 'gamma'] `%matplotlib` prevents importing * from pylab and numpy
import nengo
from nengo.utils.functions import piecewise
model = nengo.Network('Controlled Oscillator')
tau = 0.1
freq = 20
def feedback(x):
return x[1]*x[2]*freq*tau+1.1*x[0], -x[0]*x[2]*freq*tau+1.1*x[1], 0
with model:
stim = nengo.Node(lambda t: [20,20] if t<.02 else [0,0])
freq_ctrl = nengo.Node(piecewise({0:1, 2:.5, 6:-1}))
ctrl_osc = nengo.Ensemble(500, dimensions=3)
nengo.Connection(ctrl_osc, ctrl_osc, function=feedback, synapse=tau)
nengo.Connection(stim, ctrl_osc[0:2])
nengo.Connection(freq_ctrl, ctrl_osc[2])
ctrl_osc_p = nengo.Probe(ctrl_osc, synapse=0.01)
sim = nengo.Simulator(model, progress_bar=False)
sim.run(8)
figure(figsize=(12,4))
subplot(1,2,1)
plot(sim.trange(), sim.data[ctrl_osc_p]);
xlabel('Time (s)')
ylabel('State value')
subplot(1,2,2)
plot(sim.data[ctrl_osc_p][:,0],sim.data[ctrl_osc_p][:,1])
xlabel('$x_0$')
ylabel('$x_1$');
%pylab inline
import nengo
rate = False
model = nengo.Network(label='My Ensemble')
with model:
if rate:
model.config[nengo.Ensemble].neuron_type = nengo.LIFRate()
inputNode = nengo.Node(output= lambda x: 0.9 if 0.04<x<1 else 0)
population = nengo.Ensemble(200, dimensions = 1,
max_rates = Uniform(100,200))
nengo.Connection(inputNode, population, synapse=0.005,
function=lambda x: 0.05*x)
nengo.Connection(population, population, synapse=0.05,
function=lambda x: x)
inputProbe= nengo.Probe(inputNode, 'output', synapse=0.01)
populationProbe = nengo.Probe(population, 'decoded_output', synapse=0.01)
sim = nengo.Simulator(model, progress_bar=False)
sim.run(1.5)
plot(sim.data[populationProbe])
WARNING: pylab import has clobbered these variables: ['rate'] `%matplotlib` prevents importing * from pylab and numpy
[<matplotlib.lines.Line2D at 0x11baba7d0>]