Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

HopfieldBase Class Reference

A Hopfield network - content addressable memory and energy. More...

#include <HopfieldNetwork.h>

Inheritance diagram for HopfieldBase:

Inheritance graph
[legend]
Collaboration diagram for HopfieldBase:

Collaboration graph
[legend]
List of all members.

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

Detailed Description

A Hopfield network - content addressable memory and energy.

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


Member Typedef Documentation

typedef uint Nid [protected]
 

neuron interface


Constructor & Destructor Documentation

HopfieldBase  )  [inline, protected]
 

HopfieldBase uint  size,
bool  bias = false,
bool  bipolar = true
 

Creates a Hopfield network, which can store binary patterns.

Diagonal elments of the weight matrix will be zero.

Parameters:
size The size/number of bits of/in the patterns to be stored
bias true if the neurons are to have a bias, false otherwise
bipolar true if patterns are bipolar (elements are -1 or 1), false if not (elements are 0 or 1).

virtual ~HopfieldBase  )  [inline, virtual]
 


Member Function Documentation

real _getBias Nid  i  )  [protected]
 

real _getNeuronOutput Nid  n  )  const [inline, protected]
 

void _setBias Nid  i,
real  bias
[protected]
 

void _setNeuronOutput Nid  n,
real  a
[inline, protected]
 

virtual real getBias uint  i  )  [virtual]
 

Get the bias at the given neuron.

Parameters:
i The neuron whose bias is wanted
Returns:
The bias

virtual const char* getClassName  )  const [virtual]
 

Returns "HopfieldNetwork".

Implements Network.

virtual real getEnergy int  pattern[]  )  [virtual]
 

Returns the energy of the supplied pattern.

Energy of a pattern depends on the weight matrix

virtual real getEnergy  )  [virtual]
 

Returns the energy at the current state of the network.

virtual Vector getNextOutput  )  [virtual]
 

Steps the network through one unit of time and returns the output.

Returns:
A vector v, where v[i] = output of the ith neuron

virtual Vector getOutput const Vector input  )  [virtual]
 

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.

virtual Vector getOutput  )  const [virtual]
 

Returns the current outputs of the neurons.

Returns:
A vector v, where v[i] = current output at the ith neuron

std::vector<int> getOutputInt  )  const
 

getOutput clamped to {0,1} or {-1.1}

virtual uint getSize  )  const [virtual]
 

Returns the size of the patterns that can be stored (i.e., length of the pattern vector).

virtual int getTime  )  [virtual]
 

The number of steps the network has taken since the last call to getOutput.

See also:
getNextOutput

getOutput

virtual real getWeight uint  from,
uint  to
const [pure virtual]
 

Implemented in HopfieldNetwork.

virtual bool HopfieldBase::propagate const Vector pattern,
uint  timeout
[virtual]
 

the save as discrete version, but may have problems w/ convergence (real values must stand still, not only the ints

virtual bool propagate const std::vector< int > &  pattern,
uint  timeout
[virtual]
 

Sets the initial input of the network and then steps through time, returning true if the network converges before the given timeout.

Parameters:
pattern The initial output of the network
timeout The maximum number of steps the network should go through
Returns:
true if the pattern converges within the timeout, false otherwise

virtual bool propagate int  pattern[],
uint  timeout
[virtual]
 

Sets the initial input of the network and then steps through time, returning true if the network converges before the given timeout.

Parameters:
pattern The initial output of the network
timeout The maximum number of steps the network should go through
Returns:
true if the pattern converges within the timeout, false otherwise

void randomize  ) 
 

set random activations

int real2int real  r  )  const [protected]
 

conv to discrete value acc to _bipolar

virtual void save const std::string &  filename  )  [inline, virtual]
 

NOT IMPLEMENTED by default.

Implements Network.

Reimplemented in HopfieldNetwork.

virtual void setBias uint  i,
real  bias
[virtual]
 

Sets the bias of the given neuron.

Parameters:
i The neuron whose bias is to be set
bias The bias value to give the ith neuron

virtual void setInput const Vector pattern  )  [virtual]
 

Sets the initial output of the neurons to the values in the given vector and sets time to 0.

virtual void setInput const std::vector< int > &  pattern  )  [virtual]
 

Sets the initial output of the neuron to the values in the given vector of integers and sets time to 0.

Parameters:
pattern A vector of integers containing the initial outputs of the neurons. The vector must contain getSize() elements, each -1 or 1 (if bipolar) or 0 or 1 if not.

virtual void setInput int  pattern[]  )  [virtual]
 

Sets the initial output of the neurons to the values in the given array and resets time to 0.

Parameters:
pattern An array containing the initial outputs of the neurons. The array must contain getSize() elements

virtual void setWeight uint  from,
uint  to,
real  weight
[pure virtual]
 

Implemented in HopfieldNetwork.

virtual void step  )  [virtual]
 

Steps the network in time.


Member Data Documentation

bool _bipolar [protected]
 

true if patterns are bipolar (ie, elements are -1 or 1), false if not (elements are 0 or 1)

struct annie::HopfieldBase::NData _neurons [protected]
 

int _nPatterns [protected]
 

The number of patterns that have been given to the network to be stored.

int _time [protected]
 


The documentation for this class was generated from the following file:
Generated on Fri Jun 18 13:18:57 2004 for Annie by doxygen 1.3.5