Skip to content

Commit 50618be

Browse files
committed
initial commit
0 parents  commit 50618be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1771
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<img src="data/icon/icon.svg" width="64" height="64" align="left"/>
2+
3+
# hopfieldnetwork
4+
5+
>A Hopfield network is a special kind of an artifical neural network. It implements a so called associative or content addressable memory. This means that memory contents are not reached via a memory address, but that the network responses
6+
to an input pattern with that stored pattern which has the highest similarity.
7+
8+
**hopfieldnetwork** is a Python package which provides an implementation of a Hopfield network. The package also includes a graphical user interface.
9+
10+
### Requirements
11+
matplotlib
12+
numpy
13+
14+
15+
### Usage
16+
Add the Package to your Python path and import the Hopfield network class:
17+
```python
18+
from hopfieldnetwork import HopfieldNetwork
19+
```
20+
21+
Create a new Hopfield network of size _N_ = 100:
22+
```python
23+
hopfield_network1 = HopfieldNetwork(N=100)
24+
```
25+
26+
Save / Train Images into the Hopfield network:
27+
```python
28+
hopfield_network1.train_pattern(input_pattern)
29+
```
30+
31+
Start an asynchronous update with 5 iterations:
32+
```python
33+
hopfield_network1.update_neurons(iterations=5, mode=async’)
34+
```
35+
36+
Compute the energy function of a pattern:
37+
```python
38+
hopfield_network1.compute_energy(input_pattern)
39+
```
40+
41+
Save a network as a file:
42+
```python
43+
hopfield_network1.save_network(’path/to/file’)
44+
```
45+
46+
Open an already trained Hopfield network:
47+
```python
48+
hopfield_network2 = HopfieldNetwork(filepath=’network2.npz’)
49+
```
50+
51+
### Graphical user interface
52+
53+
![Hopfield network GUI](examples/project4/latex/images/gui_screenshot.png?raw=true)
54+
55+
In the Hopfield network GUI, the one-dimensional vectors of the neuron states are visualized as a two-dimensional binary image. The user has the option to load different pictures/patterns into network and then start an asynchronous or synchronous update with or without finite temperatures. There are also prestored different networks in the examples tab.
56+
57+
58+
**Run the GUI with:**
59+
60+
python2/python3 start_gui.py
61+
62+
### GUI Layout
63+
The Hopfield network GUI is divided into three frames:
64+
65+
**Input frame**\
66+
The input frame (left) is the main point of interaction with the network. The user can change the state of an input neuron by a left click to +1, accordingly by to right-click to -1. This will only change the state of the input pattern not the state of the actual network. The input pattern can be transfered to the network with the buttons below:
67+
- **Set intial** sets the current input pattern as the start configuration of the neurons.
68+
- **Save / Train** stores / trains the current input pattern into the Hopfield network.
69+
- **Rand** sets a random input pattern.
70+
- **Clear** sets all points of the input pattern to -1.
71+
72+
**Output frame**\
73+
The output frame (center) shows the current neuron configuration.
74+
- **Sync update** starts a synchronous update.
75+
- **Async update** starts an asynchronous update.
76+
- **Randomize** randomly flips the state of one tenth of the neurons.
77+
- **Set partial** sets the first half of the neurons to -1.
78+
- **Set random** sets a random neuron state.
79+
80+
**Saved pattern frame**\
81+
The Saved pattern frame (right) shows the pattern currently saved in the network.
82+
- **Set initial** sets the currently displayed image as new neuron state.
83+
- **Set input** sets the currently displayed image as input pattern.
84+
- **Remove** removes the currently displayed image from the Hopfield network.
85+
86+
**Menu bar**
87+
88+
- In the **Network** tab, a new Hopfield network of any size can be initialized.
89+
In addition, it is possible to save the current network and load stored networks. Also, a raster graphic (JPG, PNG, GIF, TIF) can be added to the network or an entirly new network can be created out of multiple images.
90+
- In the **Options** tab, the update with finite temperatures can be (de)activated.
91+
- **View** offers options for visually changing the GUI.
92+
- In the **Examples** tab, different example networks can be loaded.
5.83 KB
Binary file not shown.
Binary file not shown.

data/icon/icon.gif

21.5 KB
Loading

data/icon/icon.svg

Lines changed: 144 additions & 0 deletions
Loading
2.42 KB
Loading
4.08 KB
Loading
2.52 KB
Loading
3.06 KB
Loading

0 commit comments

Comments
 (0)