马友联盟:我想请教一下神经网络的Hopfield网络的逼近要怎样仿真?

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 09:07:39

参考一下matlab帮助
help newhop
NEWHOP Create a Hopfield recurrent network.

Syntax

net = newhop
net = newhop(T)

Description

Hopfield networks are used for pattern recall.

NET = NEWHOP creates a new network with a dialog box.

NEWHOP(T) takes one input argument,
T - RxQ matrix of Q target vectors. (Values must be +1 or -1.)
and returns a new Hopfield recurrent neural network with
stable points at the vectors in T.

Examples

Here we create a Hopfield network with two three-element
stable points T.

T = [-1 -1 1; 1 -1 1]';
net = newhop(T);

Below we check that the network is stable at these points by
using them as initial layer delay conditions. If the network is
stable we would expect that the outputs Y will be the same.
(Since Hopfield networks have no inputs, the second argument
to SIM is Q = 2 when using matrix notation).

Ai = T;
[Y,Pf,Af] = sim(net,2,[],Ai);
Y

To see if the network can correct a corrupted vector, run
the following code which simulates the Hopfield network for
five timesteps. (Since Hopfield networks have no inputs,
the second argument to SIM is {Q TS} = [1 5] when using cell
array notation.)

Ai = {[-0.9; -0.8; 0.7]};
[Y,Pf,Af] = sim(net,{1 5},{},Ai);
Y{1}

If you run the above code Y{1} will equal T(:,1) if the
network has managed to convert the corrupted vector Ai to
the nearest target vector.