Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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) #3

Open
ETERNALBLUEbullrun opened this issue Feb 11, 2024 · 2 comments

Comments

@ETERNALBLUEbullrun
Copy link

ETERNALBLUEbullrun commented Feb 11, 2024

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
@ETERNALBLUEbullrun
Copy link
Author

ETERNALBLUEbullrun commented Feb 11, 2024

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

@ETERNALBLUEbullrun
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant