Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES

 Documentation /  Neural Networks /  Hopfield Networks /  Examples /

Discrete-Time Classification of LettersContinuous-Time Classification of Letters

9.2.3 Continuous-Time Two-Dimensional Example

Load the Neural Networks package.

In[1]:=<<NeuralNetworks`

Consider the same two-dimensional example as for the discrete Hopfield network. There are two pattern vectors {1,-1} and {-1,1}, and the goal is to classify noisy versions of these vectors to the correct vector.

Generate and look at class pattern vectors.

In[2]:=x={{1,-1},{-1,1}};
NetClassificationPlot[x]

The two pattern vectors are placed in the corners of the plot.

Define a continuous-time Hopfield network with a saturated linear neuron.

Create a continuous-time Hopfield network.

In[4]:=hop=HopfieldFit[x,NetTypeRuleContinuous,NeuronRuleSaturatedLinear]

Out[4]=

Provide some information about the Hopfield network.

In[5]:=

Out[5]=

The obtained network can be used right away on any data vector by using the evaluation rule for Hopfield objects.

Evaluate the Hopfield network on a data vector.

In[6]:=hop[{0.4,-0.6}]

Out[6]=

Using NetPlot you can plot various information, for example, the state trajectories.

Plot the state trajectories.

In[7]:=NetPlot[hop,{{0.4, -0.6}}]

It might be interesting to obtain the state trajectories of the evaluation of the Hopfield network on the data vectors. This can be done by setting the option TrajectoriesRuleTrue in the evaluation of the Hopfield network.

Obtain the state trajectory.

In[8]:=

Out[8]=

The trajectory is the numerical solution to Eq. (2.28) describing the network (see Section 2.7, Hopfield Network), computed with a time step given by the variable Dt in the Hopfield object. It was automatically chosen when HopfieldFit was applied, to ensure a correct solution of the differential equation.

The energy surface and the trajectories of the data vectors can provide a vivid illustration of the classification process. This is only possible for two-dimensional continuous-time Hopfield nets.

Plot the energy surface together with the trajectories of several data vectors.

In[9]:=<< Statistics`ContinuousDistributions`
x = RandomArray[UniformDistribution[-1, 1], {30, 2}];
NetPlot[hop,x,DataFormatRuleSurface]

Discrete-Time Classification of LettersContinuous-Time Classification of Letters


Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information



 © 2009 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: