-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
96 lines (84 loc) · 4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html>
<head>
<title>Pattern retrieval and energies in a Hopfield network</title>
<link href='style.css' rel='stylesheet' type='text/css'>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body>
<h2>Pattern retrieval and energies in a Hopfield network</h2>
<p>A <a href='http://en.wikipedia.org/wiki/Hopfield_network'>Hopfield network</a> is a type of <a href='http://en.wikipedia.org/wiki/Artificial_neural_network'>neural network</a> that can be used to store patterns. This Hopfield network is implemented as follows: </p>
<ul>
<li>Each cell in the grids below corresponds to a node. Each cell is either grey ($c_i = 1$) or white ($c_i = -1$).</li>
<li>The weight matrix is defined as $ w_{ij} = \frac{1}{N} \sum_{k=1}^{N} x^{(k)}_{i} x^{(k)}_j$ where $x$ is a stored pattern and $N$ is the total number of stored pattern. It is symmetric ($w_{ij} = w_{ji}$) and there are no self connections ($w_{ii} = 0$).</li>
<li>The network is synchronously updated, with the result of one update being presented as the output.</li>
<li>The energy of the network is defined by $E = -\frac{1}{2} \sum_{ij} w_{ij} c_{i} c_{j}$ where $c$ is the current displayed pattern of the network.</li>
</ul>
<div>
<h3>Observations</h3>
<ul>
<li>Storing the same pattern more than once will lower that pattern's energy.</li>
<li>Too many similar patterns being stored may result in some superposition of the patterns being retrieved (a 'mixture state').</li>
<li>Unstable states that switch between each other can be observed.</li>
<li>The 'inverse' pattern has the same energy as the real pattern.</li>
</ul>
</div>
<h2>Hopfield network simulation</h2>
<div id='network'>
</div>
<div id='stored'>
</div>
<div id='examples'>
</div>
<script type='text/template' id='hopfield_tmpl'>
<div class='main'>
<p>
<span title="a measure of how 'stable' the pattern is"><b>Energy</b></span>: <span class='energy'>0</span>
</p>
<div id='grid_holder'>
</div>
<button title='clear the displayed pattern' id='clear'>Clear</button>
<button title='generate a random pattern' id='random'>Random</button>
<button title='invert the displayed pattern' id='invert'>Invert</button>
<br/>
<button title='train the network with the displayed pattern' id='train'>Train</button>
<button title='present the displayed pattern to the network to recall' id='recall'>Recall</button>
<br/>
Width:
<input id='cellwidth' type='number' min='1' value='5'>
Height:
<input id='cellheight' type='number' min='1' value='5'>
</div>
</script>
<script type="text/template" id='stored_tmpl'>
<div id="memories">
<h3><span class='ul'>Stored patterns</span> (<span id='num'>0</span>)</h3>
<div class="xscroller">
</div>
</div>
</script>
<script type="text/template" id='mem_tmpl'>
<div class = "mem">
<p>
<span title="a measure of how 'stable' the pattern is"><b>Energy</b></span>: <span class='energy'>0</span>
</p>
<div class="grid_holder"></div>
<button class='forget'>Forget</button>
</div>
</div>
</script>
<script src="libs/jquery-2.0.3.min.js" type="text/javascript" charset="utf-8"></script>
<script src="libs/jquery.color-2.1.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="libs/underscore-min.js" type="text/javascript" charset="utf-8"></script>
<script src="libs/backbone-min.js" type="text/javascript" charset="utf-8"></script>
<script src="libs/sylvester.js" type="text/javascript" charset="utf-8"></script>
<script src="js/grid.js" type="text/javascript" charset="utf-8"></script>
<script src="js/hopfield.js" type="text/javascript" charset="utf-8"></script>
<script src="js/main.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>