Last question has a lot going here, I divided then into small ones to conquer.
I try to have one 4x1 input vector connected with one ensemble (‘pre’) which is 4x1, in which each neural is fed one elements from the input vector. However, in GUI there are only one single slide for the input. The detail of the input says the fanout is 4, meaning there are four synaptic connection respectively to the four neurons in the ‘pre’ ensemble,but why there is only one slide to control the input instead of four ?
The codes are :
import nengo
import numpy as np
import matplotlib.pyplot as plt
model = nengo.Network()
Amat = np.array([[1,2,3,4]]) #define an array of four elements
print('Amat size:',Amat.size) #size is total elements amount
radius = 1
model = nengo.Network(label='Matrix Multiplication', seed=123)
with model:
# Make 1 Ensemble to be fed with input
pre = nengo.Ensemble(4, dimensions=1, radius=2) #4x1 dimension, matching the input
inputA = nengo.Node(Amat.size)
nengo.Connection(inputA, pre)
post = nengo.Ensemble(1, dimensions=1) # post ensemble has only one neuron.
conn = nengo.Connection(pre, post, solver=nengo.solvers.LstsqL2(weights=True))
conn.learning_rule_type = nengo.Oja(learning_rate=6e-8) #Oja learning method
Then, I have tried alternative way by using a ensembleArray which is has one block of 4 elements, still have the input vector which is defined from 4x1 array. At this time happy to see the slider has four control item seem that the input vector is indeed 4x1 as expected. But the connection between the 4x1 pre and 1x1 post report error. How the learning rule of Oja in last section can be applied as well ? I notice the difference between two ways for defining the input vector is whether using ravel() or .size to define length of the array, wasn’t the same from either one? The new code are :
model = nengo.Network()
Amat = np.array([[1],[2],[3],[4]])
Bmat = np.array([1])
print('size of Amat:',Amat.size)
model = nengo.Network(label='2x2 Oja', seed=123)
with model:
source = nengo.Node(Amat.ravel())
pre = nengo.networks.EnsembleArray(1, Amat.size, radius=1)
post = nengo.networks.EnsembleArray(1, Bmat.size, radius=1)
nengo.Connection(source, pre.input)
conn = nengo.Connection(pre.output, post.input)