set weights in projections.
I have a list of weights whose length is same as the number of connections in the projection. When i try to set it through Projection.set(weight= [list of weights]), my weights are something different than what i expected them to be. I saw this statement in lines 167-170 of pynn.common.projections.py
# Note: we have removed the option:
# "a list/1D array of the same length as the number of local connections"
# because it was proving tricky to implement and was holding up the release.
# The plan is to add this option back at a later date.
So, is there any workaround this issue? How can i set the weights? Do i have to iterate over each connection to set the weights?
I believe this still works (the documentation and the comments in the source code probably needs to be updated - shall look into this).
For this test code, we set prj.set(weight= [1,2,3,4]) for All-to-All connections between two cells. So what we expect is:
+--------+--------+--------+
| | Cell_0 | Cell_1 |
+--------+--------+--------+
| Cell_0 | 1 | 2 |
| Cell_1 | 3 | 4 |
+--------+--------+--------+
On printing the weights, we get:
Weights = [(0, 0, 1.0), (1, 0, 3.0), (0, 1, 2.0), (1, 1, 4.0)]
(each tuple contains the indices of the pre- and post-synaptic cell followed by the value of weight attribute). This confirms our expectation.
Do try this out and see if it works for you, or post more details of the discrepancy that you observed.
Hi, I looked into it. My I interpreted it wrong. You can close it.
The documentation and the comments in the source code need to be updated after verifying that there are no issues with the use of list/1D array for setting the weights.
Try to set weights for projection using a very large 1-D array(something like 10 thousand). AFAIK weights of first few IDs were set right and the remaining were scrambled. So, I had to set the weights using synapses = list(instance_of_projection.connections) and then iterate over the list of synapses to set weights. Something like:
for synapse in synapses:
synapse.weight = some_scalar_weight