In [ ]:
import nengo
model = nengo.Network(label='Combining')
with model:
# Our input ensembles consist of 100 leaky integrate-and-fire neurons,
# representing a one-dimensional signal
A = nengo.Ensemble(nengo.LIF(100), dimensions=1)
B = nengo.Ensemble(nengo.LIF(100), dimensions=1)
# The output ensemble consists of 200 leaky integrate-and-fire neurons,
# representing a two-dimensional signal
output = nengo.Ensemble(nengo.LIF(200), dimensions=2, label='2D Population')
In [ ]:
import numpy as np
with model:
# Create input nodes generating the sine and cosine
sin = nengo.Node(output=np.sin)
cos = nengo.Node(output=np.cos)
In [ ]:
with model:
nengo.Connection(sin, A)
nengo.Connection(cos, B)
# The transform defines which dimension the input will project to
nengo.Connection(A, output, transform=[[1], [0]])
nengo.Connection(B, output, transform=[[0], [1]])
In [ ]:
with model:
sin_probe = nengo.Probe(sin, 'output')
cos_probe = nengo.Probe(cos, 'output')
A_probe = nengo.Probe(A, 'decoded_output', synapse=0.01) # 10ms filter
B_probe = nengo.Probe(B, 'decoded_output', synapse=0.01) # 10ms filter
out_probe = nengo.Probe(output, 'decoded_output', synapse=0.01) # 10ms filter
In [ ]:
# Create our simulator
sim = nengo.Simulator(model)
# Run it for 5 seconds
sim.run(5)
In [ ]:
import matplotlib.pyplot as plt
# Plot the decoded output of the ensemble
plt.plot(sim.trange(), sim.data[out_probe], label="2D output")
plt.plot(sim.trange(), sim.data[A_probe], label="A output")
plt.plot(sim.trange(), sim.data[sin_probe], 'k', label="Sine")
plt.legend()
The graph shows that the input signal (Sine), the output from the 1D population (A output), and the 2D population (blue line) are all equal. The other dimension in the 2D population is shown in green.