Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import numpy as np
- import nengo
- from nengo.dists import Uniform
- from nengo.utils.matplotlib import rasterplot
- model = nengo.Network(label="overlay_test")
- with model:
- A = nengo.Ensemble(100, dimensions=1) #neurons, dimensions
- B = nengo.Ensemble(100, dimensions=1) #neurons, dimensions
- C = nengo.Ensemble(100, dimensions=1) #neurons, dimensions
- output = nengo.Ensemble(100, dimensions=2, label="2D Population") #neurons, dimensions
- #****************
- # PROVIDE INPUT
- #****************
- #input_signal = nengo.Node(lambda t: np.cos(8 * t))
- input_a = nengo.Node(output=0.5)
- input_b = nengo.Node(output=0.3)
- #****************
- # CONNECT ELEMENTS
- #****************
- #Connect the input signal to the neuron
- # The indices in neurons define which dimension the input will project to
- #nengo.Connection(input_signal, A, synapse=0.01)
- #nengo.Connection(sin, neurons[0])
- #nengo.Connection(cos, neurons[1])
- nengo.Connection(input_a, A)
- nengo.Connection(input_b, B)
- nengo.Connection(A, C)
- nengo.Connection(B, C)
- #****************
- # PROBES
- #****************
- # The original input
- #input_signal_probe = nengo.Probe(input_signal)
- input_a_probe = nengo.Probe(input_a)
- input_b_probe = nengo.Probe(input_b)
- A_probe = nengo.Probe(A, synapse=0.01) # 10ms filter
- B_probe = nengo.Probe(B, synapse=0.01) # 10ms filter
- C_probe = nengo.Probe(C, synapse=0.01) # 10ms filter
- with nengo.Simulator(model) as sim: # Create the simulator
- #****************
- # Run
- #****************
- sim.run(5) # Run it for 1 second
- #****************
- # plot the results
- #****************
- t = sim.trange()
- # Plot the decoded output of the ensemble
- plt.figure()
- plt.plot(sim.trange(), sim.data[input_a_probe], label="input a")
- plt.plot(sim.trange(), sim.data[input_b_probe], label="input b")
- plt.plot(sim.trange(), sim.data[A_probe], label="A output")
- plt.plot(sim.trange(), sim.data[B_probe], label="B output")
- plt.plot(sim.trange(), sim.data[C_probe], label="C output")
- plt.legend()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement