#include <HopfieldNetwork.h>
Inheritance diagram for HopfieldBase:
Public Member Functions | |
virtual real | getWeight (uint from, uint to) const=0 |
virtual void | setWeight (uint from, uint to, real weight)=0 |
HopfieldBase (uint size, bool bias=false, bool bipolar=true) | |
Creates a Hopfield network, which can store binary patterns. | |
virtual | ~HopfieldBase () |
virtual void | save (const std::string &filename) |
NOT IMPLEMENTED by default. | |
virtual real | getEnergy () |
Returns the energy at the current state of the network. | |
virtual real | getEnergy (int pattern[]) |
Returns the energy of the supplied pattern. | |
virtual uint | getSize () const |
Returns the size of the patterns that can be stored (i.e., length of the pattern vector). | |
virtual void | step () |
Steps the network in time. | |
virtual int | getTime () |
The number of steps the network has taken since the last call to getOutput. | |
void | randomize () |
set random activations | |
virtual const char * | getClassName () const |
Returns "HopfieldNetwork". | |
virtual real | getBias (uint i) |
Get the bias at the given neuron. | |
virtual void | setBias (uint i, real bias) |
Sets the bias of the given neuron. | |
virtual void | setInput (int pattern[]) |
Sets the initial output of the neurons to the values in the given array and resets time to 0. | |
virtual void | setInput (const std::vector< int > &pattern) |
Sets the initial output of the neuron to the values in the given vector of integers and sets time to 0. | |
virtual void | setInput (const Vector &pattern) |
Sets the initial output of the neurons to the values in the given vector and sets time to 0. | |
virtual Vector | getOutput () const |
Returns the current outputs of the neurons. | |
std::vector< int > | getOutputInt () const |
getOutput clamped to {0,1} or {-1.1} | |
virtual Vector | getNextOutput () |
Steps the network through one unit of time and returns the output. | |
virtual Vector | getOutput (const Vector &input) |
The HopfieldNetwork generally deals with vectors of integers only because the neurons are binary. | |
virtual bool | propagate (int pattern[], uint timeout) |
Sets the initial input of the network and then steps through time, returning true if the network converges before the given timeout. | |
virtual bool | propagate (const std::vector< int > &pattern, uint timeout) |
Sets the initial input of the network and then steps through time, returning true if the network converges before the given timeout. | |
virtual bool | HopfieldBase::propagate (const Vector &pattern, uint timeout) |
the save as discrete version, but may have problems w/ convergence (real values must stand still, not only the ints | |
Protected Types | |
typedef uint | Nid |
neuron interface | |
Protected Member Functions | |
HopfieldBase () | |
int | real2int (real r) const |
conv to discrete value acc to _bipolar | |
real | _getBias (Nid i) |
void | _setBias (Nid i, real bias) |
void | _setNeuronOutput (Nid n, real a) |
real | _getNeuronOutput (Nid n) const |
Protected Attributes | |
bool | _bipolar |
true if patterns are bipolar (ie, elements are -1 or 1), false if not (elements are 0 or 1) | |
int | _nPatterns |
The number of patterns that have been given to the network to be stored. | |
int | _time |
annie::HopfieldBase::NData | _neurons |
This class is an abstract base for real implementations of Hopfield
The Hopfield network is considered a landmark in the field of neural computing. This model can store a number of patterns and retrieve the correct pattern starting from a noisy or incomplete pattern so that a network can be trained to identify patterns or images. Hopfield proposed this model as a model of biological memory (often called "content addressable memory"), similar to the way a human brain recognizes an image based on the past experience or learning.
Hopfield also introduced another important idea by establishing a new connection between computation and physics with the concept of energy in his model and showed that computation can be viewed as a transition to lower energy states.
OPT: it would be faster to attach weights by a template instead of inerhitance
|
neuron interface
|
|
|
|
Creates a Hopfield network, which can store binary patterns. Diagonal elments of the weight matrix will be zero.
|
|
|
|
|
|
|
|
|
|
|
|
Get the bias at the given neuron.
|
|
Returns "HopfieldNetwork".
Implements Network. |
|
Returns the energy of the supplied pattern. Energy of a pattern depends on the weight matrix |
|
Returns the energy at the current state of the network.
|
|
Steps the network through one unit of time and returns the output.
|
|
The HopfieldNetwork generally deals with vectors of integers only because the neurons are binary. But since this class implements the Network class, it must provide this function as well, which returns the same thing as setInput() following by getOutput() would, except that the neuron's output will be of type real instead of int Implements Network. |
|
Returns the current outputs of the neurons.
|
|
getOutput clamped to {0,1} or {-1.1}
|
|
Returns the size of the patterns that can be stored (i.e., length of the pattern vector).
|
|
The number of steps the network has taken since the last call to getOutput.
|
|
Implemented in HopfieldNetwork. |
|
the save as discrete version, but may have problems w/ convergence (real values must stand still, not only the ints
|
|
Sets the initial input of the network and then steps through time, returning true if the network converges before the given timeout.
|
|
Sets the initial input of the network and then steps through time, returning true if the network converges before the given timeout.
|
|
set random activations
|
|
conv to discrete value acc to _bipolar
|
|
NOT IMPLEMENTED by default.
Implements Network. Reimplemented in HopfieldNetwork. |
|
Sets the bias of the given neuron.
|
|
Sets the initial output of the neurons to the values in the given vector and sets time to 0.
|
|
Sets the initial output of the neuron to the values in the given vector of integers and sets time to 0.
|
|
Sets the initial output of the neurons to the values in the given array and resets time to 0.
|
|
Implemented in HopfieldNetwork. |
|
Steps the network in time.
|
|
true if patterns are bipolar (ie, elements are -1 or 1), false if not (elements are 0 or 1)
|
|
|
|
The number of patterns that have been given to the network to be stored.
|
|
|