Package: hopfieldnetwork
hopfieldnetworkA 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 to an input
pattern with that stored pattern which has the highest similarity.hopfieldnetworkis a Python package which provides an implementation of a Hopfield
network. The package also includes a graphical user interface.InstallingInstall and update using pip:pipinstall-UhopfieldnetworkRequirementsPython 2.7 or higher (CPython or PyPy)NumPyMatplotlibUsageImport theHopfieldNetworkclass:fromhopfieldnetworkimportHopfieldNetworkCreate a new Hopfield network of sizeN= 100:hopfield_network1=HopfieldNetwork(N=100)Save / Train Images into the Hopfield network:hopfield_network1.train_pattern(input_pattern)Start an asynchronous update with 5 iterations:hopfield_network1.update_neurons(iterations=5,mode="async")Compute the energy function of a pattern:hopfield_network1.compute_energy(input_pattern)Save a network as a file:hopfield_network1.save_network("path/to/file")Open an already trained Hopfield network:hopfield_network2=HopfieldNetwork(filepath="network2.npz")Graphical user interfaceIn 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.Start the UI:If you installed thehopfieldnetworkpackage via pip, you can start the UI with:hopfieldnetwork-uiOtherwise you can start UI by runninggui.pyas module:python -m hopfieldnetwork.guiGUI LayoutThe Hopfield network GUI is divided into three frames:Input frameThe 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:Set intialsets the current input pattern as the start configuration of the neurons.Save / Trainstores / trains the current input pattern into the Hopfield network.Randsets a random input pattern.Clearsets all points of the input pattern to -1.Output frameThe output frame (center) shows the current neuron configuration.Sync updatestarts a synchronous update.Async updatestarts an asynchronous update.Randomizerandomly flips the state of one tenth of the neurons.Set partialsets the first half of the neurons to -1.Set randomsets a random neuron state.Saved pattern frameThe Saved pattern frame (right) shows the pattern currently saved in the network.Set initialsets the currently displayed image as new neuron state.Set inputsets the currently displayed image as input pattern.Removeremoves the currently displayed image from the Hopfield network.Menu barIn theNetworktab, a new Hopfield network of any size can be initialized.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.In theOptionstab, the update with finite temperatures can be (de)activated.Viewoffers options for visually changing the GUI.In theExamplestab, different example networks can be loaded.LicenseGNU General Public License v3.0