Hi, I am new to nengo and I am using BCM learning rules to calculate the weight matrix.
My aim is to classify the audio and I have created a three layer network so far, but when running I get
nengo.exceptions.ValidationError: Connection.learning_rule_type: Learning rule 'BCM(learning_rate=1e-10)' can only be applied on connections to neurons. Try setting `solver.weights` to True or connecting between two Neurons objects.
I’m not quite sure what the problem is, can you please answer? Thank you.
If you need more information please let me know.
Here is my code:
import random
import numpy as np
import matplotlib.pyplot as plt
from nengo.processes import WhiteSignal
#matplotlib inline
import nengo
import nengo_loihi
print(nengo.BCM.__doc__)
# def build_bcm(model, bcm, rule):
with nengo.Network(label='BCM') as model:
# model = nengo.Network()
# with model:
audio = nengo.Node(WhiteSignal(period=10420, high=5, rms=0.5), size_out=1)
pre = nengo.Ensemble(n_neurons=700, dimensions=1)
hidden = nengo.Ensemble(n_neurons=473, dimensions=1)#
nengo.Connection(audio, pre)#connect input and pre
nengo.Connection(pre, hidden)
conn_1 = nengo.Connection(pre, hidden, function=lambda x: 1, transform=1, learning_rule_type=nengo.BCM(learning_rate=1e-10))
post = nengo.Ensemble(n_neurons=10, dimensions=1)
nengo.Connection(hidden, post)
conn_2 = nengo.Connection(hidden, post, function=lambda x: 1, transform=1, learning_rule_type=nengo.BCM(learning_rate=1e-10))
#connect hidden and post
#Add in learning
with model:
error = nengo.Ensemble(700, dimensions=1)
error_p = nengo.Probe(error, synapse=0.01)
# Error = actual - target = post - pre
nengo.Connection(post, error)
nengo.Connection(pre, error, transform=-1)
# Add the learning rule to the connection
conn_1.learning_rule_type = nengo.BCM()
conn_2.learning_rule_type = nengo.BCM()
# Connect the error into the learning rule
nengo.Connection(error, conn_1.learning_rule)
nengo.Connection(error, conn_2.learning_rule)
#Probe
audio_p = nengo.Probe(audio)
pre_p = nengo.Probe(pre, synapse=0.01)
hidden_p = nengo.Probe(hidden, synapse=0.01)
post_p = nengo.Probe(post, synapse=0.01)
# Verify that it does a communication channel
with nengo_loihi.Simulator(model) as sim:#
sim.run(2.0)#