CarsonScott / HSOM

Hierarchical self-organizing maps for unsupervised pattern recognition

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

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

Fix:
sed "s/wij/wi/g" hsom/self_organizing_map.py -i'.s'