Last active
December 15, 2023 15:02
-
-
Save mfandl/4e91670f89718c017e5c5fcf7c3b644e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⍝ My attempt to implement a hopfield network with synchronous update rule in APL | |
⍝ Our network is a weight matrix created from array of patterns (vectors) | |
net ← {ws ← ⊃+⌿∘.×⍨¨⍵ ⋄ (1 1⍉ws) ← 0 ⋄ ws} | |
⍝ LHS argument is the net, RHS is the probe we want to update | |
update ← {(2×0∘<⍵+.×⍺)-1} | |
⍝ Example use | |
⍝ Here are two patterns we want to store in the network | |
patterns ← (¯1 ¯1 ¯1 1 1 1) (¯1 1 ¯1 1 ¯1 1) | |
⍝ We train the net with these patterns | |
network ← net patterns | |
⍝ We create a noisy probe | |
probe ← 1 ¯1 ¯1 1 1 1 | |
⍝ And we use the network to retrieve a memory based on the probe | |
network update probe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment