We are going to implement the functions proposed in the paper 'Hopfield network is all you need', a fantastic paper that offers an excellent introduction to contemporary Hopfield networks.
General Utility Functions
To facilitate the implementation of the Hopfield network equations, we will write some verbs that will be useful throughout our process.
rndw
This verb is explained here:
it allows generating random numbers according to a certain distribution. Literally 'weighted random'.
Example:
dot
This is matrix multiplication. More information here:
https://aplwiki.com/wiki/Inner_Product
https://en.wikipedia.org/wiki/Dot_product (en)
https://fr.wikipedia.org/wiki/Produit_matriciel (fr)
Example:
Conversion of Binary Data to Bipolar
At the beginning of the implementation of Hopfield networks, we will use binary data (referred to as patterns in the context of Hopfield networks), composed of 1s and 0s. The canonical Hopfield algorithm uses polar data, where each 0 is replaced by -1. Therefore, it is necessary to define two verbs to switch from one to the other. Note the use of ^:_1 to express the 'negation' of the first verb.
Example:
Displaying Patterns
This verb is compatible with both binary and bipolar data. It allows for a slightly more pleasant display of patterns.
Example:
To be continued
We now have everything we need to implement the equations from the paper 'Hopfield network is all you need', which we will do in a subsequent article.
Commentaires
Enregistrer un commentaire