What is the proper way to track an internal variable in a learning algorithm?

Hi community! We are developing a new custom learning rule based on PES, and we need to display changes in internal variables such as delta during simulation. We’ve attempted to implement this, but we’re unsure if it’s possible to plot the Signal variable.

p_post_trace = sim.model.sig[conn.learning_rule]["delta"]

Signal(name=Delta, shape=(4, 3))

Any good ideas or examples are welcome! Thanks! :grinning:

With the PES learning rule (and our other learning rules), it’s possible to probe the delta signal. Here’s an example:

import matplotlib.pyplot as plt
import numpy as np

import nengo
from nengo.processes import WhiteSignal

n_neurons = 100
d = 1
tsim = 10

with nengo.Network(seed=0) as net:
    u = nengo.Node(WhiteSignal(period=tsim, high=0.5))

    a = nengo.Ensemble(n_neurons, d)
    b = nengo.Ensemble(n_neurons, d)

    nengo.Connection(u, a, synapse=None)
    c = nengo.Connection(a, b, transform=0, learning_rule_type=nengo.PES(learning_rate=1e-4))

    nengo.Connection(b, c.learning_rule)
    nengo.Connection(u, c.learning_rule, transform=-1)

    up = nengo.Probe(u, synapse=0.03)
    bp = nengo.Probe(b, synapse=0.03)

    delta_p = nengo.Probe(c.learning_rule, "delta")

with nengo.Simulator(net, seed=1) as sim:

t = sim.trange()

plt.plot(t, sim.data[up])
plt.plot(t, sim.data[bp])

plt.plot(t, np.abs(sim.data[delta_p]).sum(axis=-1))

1 Like

Thanks Eric!