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

Document / parameterize hidden synapse from ensemble -> output #37

Open
arvoelke opened this issue Sep 11, 2019 · 1 comment
Open

Document / parameterize hidden synapse from ensemble -> output #37

arvoelke opened this issue Sep 11, 2019 · 1 comment

Comments

@arvoelke
Copy link

self.connection = nengo.Connection(
self.ensemble, self.output, function=function,
transform=transform, eval_points=eval_points,
learning_rule_type=nengo.PES(learning_rate))

A synapse (that is not directly configurable) is created on this connection to the output node. This results in slightly different results between FpgaPesEnsembleNetwork and a corresponding Ensemble both with the same nengo.Simulator. A workaround is to configure fpga_pes_ensemble_network.connection.synapse = None after creating the network.

Here's a quick unit test that demonstrates identical behaviour with this work-around:

import nengo
from nengo_fpga.networks import FpgaPesEnsembleNetwork

n = 1
neuron_type = nengo.SpikingRectifiedLinear()
rate = 100
probe_tau = 0.1
sim_t = 20

# 1) Nengo Ensemble implementation
with nengo.Network() as model1:
    a1 = nengo.Ensemble(
        n_neurons=n,
        dimensions=1,
        neuron_type=neuron_type,
        gain=np.zeros(n),
        bias=rate*np.ones(n),
    )
    
    p1 = nengo.Probe(a1.neurons, synapse=probe_tau)
    
# 2) Equivalent FpgaPesEnsembleNetwork implementation
with nengo.Network() as model2:
    a2 = FpgaPesEnsembleNetwork(
        fpga_name='foobar',
        n_neurons=n,
        dimensions=n,
        learning_rate=0,
    )
    a2.ensemble.gain = np.zeros(n)
    a2.ensemble.bias = rate*np.ones(n)
    a2.ensemble.neuron_type = neuron_type
    a2.connection.solver = nengo.solvers.NoSolver(np.eye(n))
    a2.connection.synapse = None  # <- this is the important line
    
    p2 = nengo.Probe(a2.output, synapse=probe_tau)

# Compare for equality using the same simulator
with nengo.Simulator(model1) as sim1:
    sim1.run_steps(sim_t)

with nengo.Simulator(model2) as sim2:
    sim2.run_steps(sim_t)
    
assert np.allclose(sim1.data[p1], sim2.data[p2])
@arvoelke
Copy link
Author

arvoelke commented Sep 16, 2019

Found some unexpected behaviour with the above example. If I switch the second simulator to nengo_fpga.Simulator, the fpga_name to an existing board, and a2.connection.synapse to something other than None, then that synapse appears to be ignored. For instance, moving the probe_tau from the probe to the connection does not seem to work (the output is still spikes).

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