-
-
Save hunse/6766f39354418fd32c4a39b17c81577e to your computer and use it in GitHub Desktop.
Count how many Loihi neurons are redundant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
import nengo | |
import nengo_loihi | |
def test(n_trials=3): | |
neurons = np.logspace(1, 3, 20).astype(int) | |
result = np.zeros((len(neurons), n_trials)) | |
for i, n in enumerate(neurons): | |
for k in range(n_trials): | |
with nengo.Network() as net: | |
nengo_loihi.config.set_defaults() | |
u = nengo.Node(1.) | |
a = nengo.Ensemble(n, 1) | |
c = nengo.Connection(u, a) | |
with nengo_loihi.Simulator(net) as sim: | |
block = sim.model.objs[a.neurons]['out'] | |
comp = block.compartment | |
assert len(block.synapses) == 1 | |
syn = block.synapses[0] | |
keys = list(zip(comp.bias, syn.weights[0][0])) | |
result[i, k] = len(np.unique(keys, axis=0)) / n | |
return neurons, result | |
neurons, result = test(n_trials=5) | |
plt.semilogx(neurons, result.mean(axis=1)) | |
plt.semilogx(neurons, result.max(axis=1)) | |
plt.semilogx(neurons, result.min(axis=1)) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment