Generating an error signal using BCM learning rule

When I am using the BCM learning rule to generate error signals, there is a

ValidationError: '<LearningRule modifying <Connection from <Ensemble (unlabeled) at 0x11872be50> to <Ensemble (unlabeled) at 0x11872ba60>> with type BCM()>' must have size_in > 0.

I don’t know where I set the size_in to be less than 0.
My code is below:

with model:
    sin = nengo.Node(WhiteSignal(700, high=5), size_out=1)
    pre = nengo.Ensemble(700, dimensions=1)
    post = nengo.Ensemble(20, dimensions=1)

    nengo.Connection(sin, pre)
    conn = nengo.Connection(pre, post, solver=nengo.solvers.LstsqL2(weights=True))

    sin_p = nengo.Probe(sin)
    pre_p = nengo.Probe(pre, synapse=0.01)
    post_p = nengo.Probe(post, synapse=0.01)
    conn.learning_rule_type = nengo.BCM(learning_rate=5e-10)
with model:
    weights_p = nengo.Probe(conn, "weights", synapse=0.01, sample_every=0.01)

with model:
    error = nengo.Ensemble(700, dimensions=1)
    error_p = nengo.Probe(error, synapse=0.03)

    # Error = actual - target = post - pre
    nengo.Connection(post, error)
    nengo.Connection(pre, error, transform=-1)

    # Add the learning rule to the connection
    conn.learning_rule_type = nengo.BCM()

    # Connect the error into the learning rule
    nengo.Connection(error, conn.learning_rule)

Thank you for your heip!

I’ll have to double check with @tbekolay (he is the creator of the BCM rule), the BCM rule is an unsupervised learning rule. This is to say that it does not use an “error signal” to compute the weight changes to be applied to the connection weights. Rather (as stated in the documentation), the weight changes are computed as a function of the activities of the pre-synaptic population and the post-synaptic population.

Since the BCM learning rule isn’t expecting an error signal input connection, Nengo throws the ValidationError when you attempt to do this.