hsom/self_organizing_map.py:99,23 is a "j", should just have a space. Result is a bug (won't cutoff to 4 max)
ETERNALBLUEbullrun opened this issue · comments
TermuxFan commented
wij
is unused
https://github.com/CarsonScott/HSOM/blob/master/hsom/self_organizing_map.py
def compute_weights(self, sample):
for winner in self.winners:
W = self.nodes[winner]
h = self.thresholds[winner]
y = self.outputs[winner]
x = self.inputs[winner]
dh = self.learning_rate * (x - h)
h += dh
for i in range(len(W)):
if sample[i] == 1:
dwi = self.learning_rate * y
else:
dwi = -self.learning_rate * y
wi = W[i]
wi += dwi
if abs(wi) > 4:
wij = 4 * sign(wi)
W[i] = wi
self.nodes[winner] = W
self.thresholds[winner] = h
TermuxFan commented
Fix:
sed "s/wij/wi/g" hsom/self_organizing_map.py -i'.s'
TermuxFan commented