-
Notifications
You must be signed in to change notification settings - Fork 1
/
somTrain.m
38 lines (28 loc) · 956 Bytes
/
somTrain.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function somTrain(patterns)
% patterns -> DxP, each column is a pattern x
global maxNeighborDist tuneND orderLR orderSteps tuneLR P;
% Ordering Phase %
%Create matrices which contain exponentially declining values from:
% i) maxNeighborDist to TuneND
% ii)orderLR to tuneLR
OrderingND = linspace(maxNeighborDist,tuneND,orderSteps);
OrderingLR = linspace(orderLR,tuneLR,orderSteps);
for i=1:orderSteps
neighborDist = OrderingND(i);
learningRate = OrderingLR(i);
%Train for each of P - patterns
for j=1:P
somUpdate(patterns(:,j), learningRate, neighborDist);
end
end
% Tuning Phase %
neighborDist = tuneND ;
learningRate = tuneLR ;
coeff = 4; %coefficient values range from 2 to 5
tuningSteps = orderSteps * coeff;
for i=1:tuningSteps
%Train for each of P - patterns
for j=1:P
somUpdate(patterns(:,j), learningRate, neighborDist);
end
end