What is wrong with this? (Beginner question)

Joaquin Sitte j.sitte at qut.edu.au
Wed May 25 02:13:52 UTC 2005

In the course of implementing a Self-organising feature map (SOM) I needed
to initialise the weight vecorts of each of nodes in the map with random
numbers. I wrote the method randomWeights below for the class Som 

ArrayedCollection variableSubclass: #Som
	instanceVariableNames: 'width height'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'NeuralNets'

	"initialise the weights of the neurones to random vectors"
	"JS 5/24/2005 23:14 Caution: all rendome vectors are the same. Why?"
	|randomGenerator |
	randomGenerator _ Random new.
	self do: [ :each |  1 to: each size do:
		[:index | each at: index put: randomGenerator next]].

It turns out that the weight vectors of each of the nodes in the SOM are set
to the SAME random vector, when I expected them to be all DIFFERENT. What is
wrong with this nested iteration?

The following trial in a workspace 

map _ Som new: 30
map width:6 height:5 inputs: 4
count _1.
1 to: 30 do: [ :each | (map at: each) at: 1 put: count. Count _ count + 1]. 

sets the first weight of each of the 30 nodes to 30 !!!  I would expect them
to be set to 1, 2, ... 30.

Please help.




Dr. Joaquin Sitte, Associate Professor.
Head, Smart Devices Lab
School of Software Engineering and Data Communication
Faculty of Information Technology
Queensland University of Technology
GPO Box 2434, Brisbane, Q 4001
Phone +61 7 3864 9325
Fax +61 7 3864 9390
e-mail j.sitte at qut.edu.au 
homepage http://www.fit.qut.edu.au/~sitte

More information about the Squeak-dev mailing list