Study on neural network Hopfield

Source: Internet
Author: User

Hopfield Neural network usage instructions.

There are two characteristics of this neural network:

1, output value is only 0, 1

2,hopfield not entered (input)

Here's a second feature, what do you mean no input? Because in the use of Hopfield network, more used for image simulation, image simulation means to give you some standard images first,

such as the number of 1~9, and then use some other test images (blurred, let people recognize the basic half guess half) to approximate the standard image. The so-called no input means that the image you have entered is

Output, then hopfield that there is no input. MATLAB Official Note: Since Hopfield networks have no Inputs......balabala

Then we actually use the nerve to simulate digital pictures, examples of using the network to identify the "" "example, but the specific explanation for the original, but also here to abandon some online baseless assertion error interpretation.

Hopfield Call Flow:

1 Newhop ()
function function: Create a discrete Hopfield network.
Call format: Net=newhop (T);

Here T represents the output, explained above, why T is not input, T is the matrix of m*n

2,sim () function

% call format: [Y,af,e,perf] = SIM (net,p,[],ai,t)
% [Y,af,e,perf] = Sim (net,{q ts},ai,t)
%
% P,q: The number of test vectors;
% Ai: initial layer delay, default is 0;
% T: Test vectors;
% TS: The number of steps to test;
% Y: The output vector of the network;
% Af: The layer delay state at the end of the training;
% E: Error vector;
% Perf: Network performance.

This is an excerpt from the network, obviously not clear enough, we use MATLAB is help example illustrate.

Here we create a Hopfield network with a three-element
Stable points T.
Create a Hopfield network of T
T = [-1-1 1; 1-1 1] ';
NET = Newhop (T);


Below we check that the network was stable at these points by
Using them as initial layer delay conditions. If the network is
Stable we would expect that the outputs Y'll be the same.
(Since Hopfield networks have no inputs, the second argument
To SIM was Q = 2 when using matrix notation).
We check the built network with the initialization data, and if the network is stable, the y that we output is the input Y.
Ai = T;
[Y,pf,af] = SIM (Net,2,[],ai);
Y

Add, four parameters of SIM:

net--represents the network established by Newhop

2--represents the number of columns of T (sample Dimension), where T is the 4*2 dimension after transpose

[]--indicates that the input t is a matrix form

ai--the data that needs to be emulated, which means testing with the original data

PS: in matrix form, the default neuron is a layer, that is, the TS step is 1

Next we'll call the multi-step method.
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 are {Q TS} = [1 5] when using cell
Array notation.)
With the method of multi-step, it is necessary to use the cell structure of MATLAB (cell)

Here is a description of the usage of the cell:

X={x1,x2,x3 ... },xi can be any data, or it can be a cell

The invocation of X (1) means that the X1 is taken, which is understood to fetch an object, while X{1} is the X1 (http://jingyan.baidu.com/article/20095761997932cb0721b485.html)

Ai = {[-0.9;-0.8; 0.7]};
[Y,pf,af] = Sim (Net,{1 5},{},ai);
Y{1}
Parameter description:

ai--encapsulate 3*1 vectors as cell structures

{1,5}--1 indicates that the AI's dimension 1,5 is represented by step 5, or 5-layer neurons

{}--means to tell the function that the data is passed in the cell format

ai--testing Network with original data

Important The SIM simulation function is a lateral simulation, that is, the number of columns as the simulation unit, for example, in the following code T is the number "1", "2" picture merge, picture format is 12*10, merged to 24*10.

But before the simulation, as the simulation direction according to the unit, the need to transpose to 10*24, you can image understanding of the picture in the horizontal arrangement.

Therefore, the dimension is set in 12 (one picture).

The function is finished, to analyze the digital identification code given on the Internet:

%------------------------------Number Array--------------------------------- One=[-1-1-1-1-1-1-1-1-1-1;...     -1-1-1-1 1 1-1-1-1-1;-1-1-1-1 1 1-1-1-1-1;...     -1-1-1-1 1 1-1-1-1-1;-1-1-1-1 1 1-1-1-1-1;...     -1-1-1-1 1 1-1-1-1-1;-1-1-1-1 1 1-1-1-1-1;...     -1-1-1-1 1 1-1-1-1-1;-1-1-1-1 1 1-1-1-1-1;...     -1-1-1-1 1 1-1-1-1-1;-1-1-1-1 1 1-1-1-1-1;...     -1-1-1-1-1-1-1-1-1-1];two=[-1-1-1-1-1-1-1-1-1-1;...     -1 1 1 1 1 1 1 1 1-1;-1 1 1 1 1 1 1 1 1-1;...     -1-1-1-1-1-1-1 1 1-1;-1-1-1-1-1-1-1 1 1-1;...     -1 1 1 1 1 1 1 1 1-1;-1 1 1 1 1 1 1 1 1-1;...     -1 1 1-1-1-1-1-1-1-1;-1 1 1-1-1-1-1-1-1-1;...     -1 1 1 1 1 1 1 1 1-1;-1 1 1 1 1 1 1 1 1-1;...     -1-1-1-1-1-1-1-1-1-1];%--------------------------Plot standard number Figure--------------Subplot (2,3,1) Imshow (Imresize (one, -)) title (' Standard Number') Subplot (2,3,4) Imshow (Imresize ( -)) title (' Standard Number')%---------------------------creat Hopfield Net---------------------T=[one;two]';net=Newhop (T);%--------------------------Generate Rand Noise------------------ forI=2: One     forj=2:9a=Rand; ifa<=0.1One (i,j)=-One (I,J); Both (I,J)=-(I,J); End Endendnoise_one=Onenoise_two= Both%-------------------------plot noise Figure----------------------------Subplot (2,3,2) Imshow (Imresize (Noise_one, -)) title ('Noise Number') Subplot (2,3,5) Imshow (Imresize (Noise_two, -)) title ('Noise Number')

The above buy-in for displaying pictures and adding noise after displaying pictures, there is no need for analysis.

%------------------------plot identify figure---------------------------
Noise1={(Noise_one)'};% the diagram into a cell structure and transpose (horizontal picture arrangement)Tu1=sim (net,{ A,3},{},noise1);% per 12 megapixels is a pictureSubplot (2,3,3)
% back to the picture and show, here to add, {3} indicates that there are three layers of neural network output, take the third layer output value
Imshow (Imresize (tu1{3}', 20)) % magnification 20 times timesTitle'Identify number') Noise2={(Noise_two)'};Tu2=sim (net,{ A,3},{},noise2); tu2{3}'Subplot (2,3,6) Imshow (imresize (tu2{3}',))Title'Identify number')

Extension: In fact, according to the description of the SIM function, the following two ends of the code effect is the same, but the cell can only be a layer of neural network

% with cell 
noise1={(noise_one) " }; Tu1=sim (Net,{12 , 1 },{},noise1); %tu1{3 } Subplot ( 2 , 3 , 3 ) Imshow (Imresize (tu1{ 1 } ,20) title (" identify number ")
% with matrix
noise1= (noise_one)'; Tu1=sim (NET,N, [],noise1); %tu1{3}'subplot (2,3,6) imshow (imresize (tu1' ) ,)) Title ('identifynumber')

Study on neural network Hopfield

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.