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

Force Loihi solvers to use weights=True #230

Open
arvoelke opened this issue Jun 13, 2019 · 1 comment
Open

Force Loihi solvers to use weights=True #230

arvoelke opened this issue Jun 13, 2019 · 1 comment

Comments

@arvoelke
Copy link
Contributor

arvoelke commented Jun 13, 2019

Continuation of #74.

Setting the solver to weights=True can improve accuracy by avoiding the use of DecodeNeurons, especially in the context of recurrent connections. I can add some examples in #224 to demonstrate.

One reason this is necessary is because weights=True can't be set on a passthrough connection. e.g., if you have x -> passthrough -> x as in the docs/examples/integrator_multi_d.ipynb example. Even though the passthrough ends up getting removed, there's no way to signal to the backend that I'd like to have the new connection use weights=True.

This cannot be done at the config level because if the network contains a node then you get the error:

nengo.exceptions.ValidationError: Connection.solver: weight solvers only work for connections from ensembles (got 'Node')
@arvoelke
Copy link
Contributor Author

Here's a quick work-around that seems to do the trick (can add this to the top of your model):

# jupyter-specific: guard against this cell being re-run
if 'orig_build_chip_connection' not in locals():
    orig_build_chip_connection = (
        nengo_loihi.builder.connection.build_chip_connection)

    def monkeypatched_build_chip_connection(model, conn):
        # https://github.com/nengo/nengo-loihi/issues/230
        if (isinstance(conn.pre, nengo.Ensemble)
                and isinstance(conn.post, nengo.Ensemble)):
            print("Forcing neuron-to-neuron: %s" % conn)
            conn.solver = nengo.solvers.LstsqL2(weights=True)
        return orig_build_chip_connection(model, conn)

    nengo_loihi.builder.connection.build_chip_connection = (
        monkeypatched_build_chip_connection)

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

No branches or pull requests

1 participant