-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
I did a little benchmarking of an integrator network, for several different inputs:
- Cosine
- Step-function
- Zero (holding steady at 1)
I measured the RMSE across multiple trials with different seeds, while varying the gain on the recurrent feedback.
For the reference simulator, a recurrent transform of 1 is optimal. But here, I'm getting 1.12 - 1.15, depending on the kind of input. I'm not using any interneurons, and I'm using a fairly long time-constant (100 ms).
Might be useful to eventually have a collection of similar benchmarks in a regression test framework.
from collections import defaultdict
import numpy as np
from pandas import DataFrame
import matplotlib.pyplot as plt
import seaborn as sns
import nengo_loihi; nengo_loihi.set_defaults()
import nengo
from nengo.utils.numpy import rmse
from nengolib.signal import s
n_neurons = 300
conn_tau = 0.1
probe_tau = 0.005
dt = 0.001
sim_t = 2*np.pi
simulator = nengo_loihi
data = defaultdict(list)
for desc, output in [('Cosine', np.cos),
('Step', 1. / sim_t),
('Zero', lambda t: 1 if t <= 1 else 0)]:
for seed in range(5):
for transform in np.linspace(1.05, 1.2, 10):
print("desc=%s, seed=%d, transform=%s" % (desc, seed, transform))
with nengo.Network() as model:
u = nengo.Node(output=output)
x = nengo.Ensemble(n_neurons, 1, seed=seed)
nengo.Connection(u, x, synapse=conn_tau, transform=conn_tau)
nengo.Connection(x, x, synapse=conn_tau, transform=transform,
solver=nengo.solvers.LstsqL2(weights=True))
p_x = nengo.Probe(x, synapse=probe_tau)
p_ideal = nengo.Probe(u, synapse=~s * nengo.Lowpass(probe_tau))
builder_model = simulator.builder.Model(dt=dt)
# builder_model.inter_tau = inter_tau
# assert builder_model.inter_n == 10 # sanity check
# builder_model.inter_n = inter_n
# builder_model.inter_noise_exp = 5
with simulator.Simulator(network=model, model=builder_model, dt=dt) as sim:
sim.run(sim_t)
data['x'].append(sim.data[p_x].squeeze())
data['Input'].append(desc)
data['RMSE'].append(rmse(sim.data[p_x], sim.data[p_ideal]))
data['Seed'].append(seed)
data['Transform'].append(transform)
df = DataFrame(data)
plt.figure()
plt.title("Integration Performance")
sns.lineplot(data=df, x="Transform", y="RMSE", hue="Input", ci=95)
plt.show()Also see #90 which may be related.
Metadata
Metadata
Assignees
Labels
No labels
