Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Hopfield Network Example Training and Testing:

Training:
Binary Patterns: P1 =1110, P2 = 0001 Threshold=1

Weight Update rule: (2xi -1)(2xj-1) where i not equal to j

Initial weight matrix

0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0

Weight Update for First Pattern P1= 111O

1 1 1 0
1 0 1 1 -1
1 1 0 1 -1
1 1 1 0 -1
0 -1 -1 -1 0

Weight Update for Second Pattern P2= 0001


Initial weight matrix after training with P1:
0 0 0 1
0 0 1 1 -1
0 1 0 1 -1
0 1 1 0 -1
1 -1 -1 -1 0

0 0 0 1
0 0 2 2 -2
0 2 0 2 -2
0 2 2 0 -2
1 -2 -2 -2 0

Recall or Testing
Suppose the first pattern P1 is distorted to 0110
0 1 1 0 Update
First neuron
0 2 2 -2 4=1 (changed)
2 0 2 -2
2 2 0 -2
-2 -2 -2 0

1 1 1 0 Update
Third neuron
0 2 2 -2
2 0 2 -2
2 2 0 -2 4=1 (no change)
-2 -2 -2 0

1 1 1 0 Update fourth
neuron
0 2 2 -2
2 0 2 -2
2 2 0 -2
-2 -2 -2 0 -6=0 (no change)

1 1 1 0 Update second
neuron
0 2 2 -2
2 0 2 -2 4=1 (no change)
2 2 0 -2
-2 -2 -2 0
So, the pattern that will be recalled after seeing 0110 is 1110.
Suppose we are feeding slightly distorted version of pattern P2 i.e., 1001
1 0 0 1 Update second
neuron
0 2 2 -2
2 0 2 -2 0=0 (no change)
2 2 0 -2
-2 -2 -2 0

1 0 0 1 Update first
neuron
0 2 2 -2 -2 = 0 (changed)
2 0 2 -2
2 2 0 -2
-2 -2 -2 0 -2 =0 (changed)

0 0 0 1 Update third
neuron
0 2 2 -2
2 0 2 -2
2 2 0 -2 -2 =0 (changed)
-2 -2 -2 0

0 0 0 1 Update fourth
neuron
0 2 2 -2
2 0 2 -2
2 2 0 -2
-2 -2 -2 0

You might also like