Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple sliced Neuron->Neuron connections do not work properly #167

Open
hunse opened this issue Apr 3, 2020 · 0 comments
Open

Multiple sliced Neuron->Neuron connections do not work properly #167

hunse opened this issue Apr 3, 2020 · 0 comments

Comments

@hunse
Copy link
Collaborator

hunse commented Apr 3, 2020

https://forum.nengo.ai/t/connecting-ensembles-using-neuron-clusters-second-question-added/1121/4

Doing multiple connections from different slices of neurons in an ensemble to the same target does not work properly.

Minimal example, where the output should be a sine wave with amplitude between -1 and 1. Works properly in Nengo.

import matplotlib.pyplot as plt
import nengo
import nengo_ocl
import numpy as np

with nengo.Network() as model:
    inp = nengo.Node(lambda t: np.sin(6*t))
    ens1 = nengo.Ensemble(20, 1, seed=1, label="a")
    node2 = nengo.Node(size_in=1)
    node2_p = nengo.Probe(node2, synapse=0.03)
    nengo.Connection(inp, ens1, synapse=None)

    # Make temporary connection and use it to retrieve weights
    conn = nengo.Connection(
        ens1, node2, solver=nengo.solvers.LstsqL2(), seed=3
    )

    with nengo.Simulator(model) as sim:
        weights = sim.data[conn].weights

    model.connections.remove(conn)

    # Make connections between clusters
    Ncluster = 10  # number of neurons per cluster
    clusters1 = np.arange(0, ens1.n_neurons, Ncluster)

    if 0:
        nengo.Connection(ens1.neurons, node2, transform=weights)
    else:
        for i, begin1 in enumerate(clusters1):
            end1 = begin1 + Ncluster

            nengo.Connection(
                ens1.neurons[begin1:end1],
                node2,
                transform=weights[:, begin1:end1],
                label="a%d-b" % (i,)
            )

# with nengo.Simulator(model) as sim:
with nengo_ocl.Simulator(model) as sim:
    sim.run(1.0)

plt.plot(sim.trange(), sim.data[node2_p])
plt.ylim([-1, 1])

plt.show()

Figure_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant