Examples‎ > ‎

Hopfield neural network test

Hopfield networks may be used to solve the recall problem of matching cues for an input pattern to an associated pre-learned pattern.
They are form of recurrent artificial neural networks, which serve as content-addressable memory systems with binary threshold nodes.
This test shows an use-case of Hopfield network used as auto-associative memory.
In this example we recognize 100-pixel picture with the 100-neuron neural network.
Star '*' pixel is represented by 1 and empty ' ' is represented by -1. In this way we obtained test vectors that have 100 components.
When the test vector, which is passed to input of the network, is identical with one of the pattern vectors, the net does not change its state.
It recognizes also test vectors that are similar to patterns.

The net learns the following images:
+----------+ +----------+ +----------+ 
|   ***    | |**********| |*****     | 
|  ****    | |**********| |*****     | 
| *****    | |**********| |*****     | 
|   ***    | |**********| |*****     | 
|   ***    | |**********| |*****     | 
|   ***    | |          | |     *****| 
|   ***    | |          | |     *****| 
|   ***    | |          | |     *****| 
| *******  | |          | |     *****| 
| *******  | |          | |     *****| 
+----------+ +----------+ +----------+ 
+----------+ +----------+
|**********| |**********|
|**********| |*        *|
|**      **| |* ****** *|
|**      **| |* *    * *|
|**      **| |* * ** * *|
|**********| |* * ** * *|
|**********| |* *    * *|
|**      **| |* ****** *|
|**      **| |*        *|
|**      **| |**********|
+----------+ +----------+

Sometimes we can see another feature of Hopfield network – remembering relations between neighboring pixels without their values. 
As a result of network activity we get the picture that is the reversed pattern.




Then for each test-image it recalls the most similar of those learnt, 
as shown in the following example:

THIS IMAGE     RECALLS 
+----------+  +----------+
|   ***    |  |   ***    |
|   ***    |  |  ****    |
|   ***    |  | *****    |
|   ***    |  |   ***    |
|   ***    |  |   ***    |
|   ***    |  |   ***    |
|   ***    |  |   ***    |
|   ***    |  |   ***    |
|   ***    |  | *******  |
|   ***    |  | *******  |
+----------+  +----------+


 THIS IMAGE      RECALLS  
+----------+  +----------+
|**********|  |**********|
|**********|  |**********|
|          |  |**********|
|          |  |**********|
|          |  |**********|
|          |  |          |
|          |  |          |
|          |  |          |
|          |  |          |
|          |  |          |
+----------+  +----------+


 THIS IMAGE      RECALLS 
+----------+  +----------+
|          |  |*****     |
|          |  |*****     |
|*****     |  |*****     |
|*****     |  |*****     |
|*****     |  |*****     |
|     *****|  |     *****|
|     *****|  |     *****|
|     *****|  |     *****|
|          |  |     *****|
|          |  |     *****|
+----------+  +----------+


 THIS IMAGE      RECALLS  
+----------+  +----------+
|**********|  |**********|
|*        *|  |**********|
|*        *|  |**      **|
|*        *|  |**      **|
|*        *|  |**      **|
|**********|  |**********|
|**********|  |**********|
|*        *|  |**      **|
|*        *|  |**      **|
|*        *|  |**      **|
+----------+  +----------+


 THIS IMAGE      RECALLS  
+----------+  +----------+
|**********|  |**********|
|*        *|  |*        *|
|* ****** *|  |* ****** *|
|* *    * *|  |* *    * *|
|* *    * *|  |* * ** * *|
|* *    * *|  |* * ** * *|
|* *    * *|  |* *    * *|
|* ****** *|  |* ****** *|
|*        *|  |*        *|
|**********|  |**********|
+----------+  +----------+

Comments