Classification of Discrete Hopfield Neural Networks——Evaluation of Scientific Research Capabilities of Universities

discrete Hopfield network

Discrete Hopfield network is a classic neural network model. Its basic principle is to use discretized neurons and discretized weight matrix to realize the functions of pattern recognition and pattern restoration. It was first proposed by American physicist John Hopfield in 1982. It is a single-layer fully connected neural network, which is widely used in pattern recognition, optimization problems, self-organizing learning and other fields.

The basic structure of the discrete Hopfield network consists of n discretized neurons and a fully connected weight matrix between them. Each neuron can only take two values, usually 1 and -1. Each element in the weight matrix represents the strength of the connection between two neurons, i.e. how much they influence each other. The learning rule of the discrete Hopfield network is based on the Hebbian learning rule, that is, when two neurons are activated at the same time, the connection strength between them increases.

The main functions of discrete Hopfield networks include pattern storage, pattern recognition and pattern recovery. In the pattern storage stage, the network will store the patterns in the training set into the weight matrix, so that each pattern becomes an attractor of the network. In the pattern recognition stage, when the network receives an input pattern, it will generate a new state through the interaction between neurons, and find the closest attractor in the weight matrix to restore the input pattern to the closest training mode. If the network cannot recover a complete pattern, it will stay in local minima or go into oscillations.

In conclusion, discrete Hopfield network is a simple but powerful neural network model, which has good performance in pattern recognition and pattern recovery, but also has some limitations and defects, such as limited storage capacity, easy to fall into local minimum, etc. .

Unlike the "hierarchical" neural network structure adopted by the multi-layer perceptron , the Hopfield neural network is based on an "interconnected" and recursive network.

  • From the point of view of learning , it is a powerful learning system with simple structure and easy programming.

  • From the point of view of the system , it is a static nonlinear mapping, and the nonlinear processing capability of complex systems can be obtained through the compound mapping of simple nonlinear processing units.

  • From a computational point of view, it is not a robust system and lacks rich dynamical behavior.

Features of the Hopfield network:

Neurons can take binary values ​​{0/1} or {-1/1}, where the synaptic weight between any neuron i and j is Wij, and the connection between neurons is symmetrical, that is, Wij = Wji ; and neurons themselves have no connections, but each neuron is connected to other neurons.

Each neuron transmits its output to other neurons through synaptic weights, and each neuron receives information from other neurons, so that for each neuron, its output signal passes through Other neurons may then feed back to themselves, so the Hopfield network is a feedback neural network.

The principles of other bloggers will be much more detailed than mine. It is recommended to read the explanations of other bloggers, and then look at my actual examples for better results.

code details

Chapter1

%% 离散Hopfield的分类——高校科研能力评价

%% 清空环境变量
clear all
clc

%% 导入数据
load class.mat

%% 目标向量
T = [class_1 class_2 class_3 class_4 class_5];

%% 创建网络
net = newhop(T);

%% 导入待分类样本
load sim.mat
A = {[sim_1 sim_2 sim_3 sim_4 sim_5]};

%% 网络仿真
Y = sim(net,{25 20},{},A);

%% 结果显示
Y1 = Y{20}(:,1:5)
Y2 = Y{20}(:,6:10)
Y3 = Y{20}(:,11:15)
Y4 = Y{20}(:,16:20)
Y5 = Y{20}(:,21:25)

%% 绘图
result = {T;A{1};Y{20}};
figure
for p = 1:3
    for k = 1:5 
        subplot(3,5,(p-1)*5+k)
        temp = result{p}(:,(k-1)*5+1:k*5);
        [m,n] = size(temp);
        for i = 1:m
            for j = 1:n
                if temp(i,j) > 0
                   plot(j,m-i,'ko','MarkerFaceColor','k');
                else
                   plot(j,m-i,'ko');
                end
                hold on
            end
        end
        axis([0 6 0 12])
        axis off
        if p == 1
           title(['class' num2str(k)])
        elseif p == 2
           title(['pre-sim' num2str(k)])
        else
           title(['sim' num2str(k)])
        end
    end                
end

% 案例扩展(无法分辨情况)
noisy = [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];
y = sim(net,{5 100},{},{noisy});
a = y{100}

Read me

文件说明:

1. chapter1.m为主程序,将该文件夹设置为MATLAB当前工作路径,运行即可。

2. class.mat为五个理想的等级评价指标编码矩阵,sim.mat为5所待分类高校的等级评价指标编码矩阵。

3. stdlib.m为利用MATLAB自带工具箱创建的一个离散型Hopfield网络例子,test.m为与之对应的神经网络工具箱函数拆解的程序(具体在配套的视频中有详细的讲解)。

4. 该程序在MATLAB2009a版本下测试通过,个别函数在低版本中不存在或者调用格式有所不同,参照对应版本中的帮助文档修改即可。

stdlib

%% 离散Hopfield的分类——高校科研能力评价

%% 清空环境变量
clear all
clc

%% 导入记忆模式
T = [-1 -1 1; 1 -1 1]';

%% 创建网络
net = newhop(T);

%% 导入待记忆模式
Ai = {[-0.7; -0.6; 0.6]};

%% 网络记忆
a = sim(net,{1,5},{},Ai);
a{1}

Test

%% 离散Hopfield的分类——高校科研能力评价

%% 清空环境变量
clear all
clc

%% 导入记忆模式
T = [-1 -1 1; 1 -1 1]';

%% 权值和阈值学习
[S,Q] = size(T);
Y = T(:,1:Q-1) - T(:,Q)*ones(1,Q-1);
[U,SS,V] = svd(Y);
K = rank(SS);

TP = zeros(S,S);
for k = 1:K
  TP = TP + U(:,k)*U(:,k)';
end

TM = zeros(S,S);
for k = K+1:S
  TM = TM + U(:,k)*U(:,k)';
end

tau = 10;
Ttau = TP - tau*TM;
Itau = T(:,Q) - Ttau*T(:,Q);

h = 0.15;
C1 = exp(h)-1;
C2 = -(exp(-tau*h) - 1)/tau;

w = expm(h*Ttau);
b = U * [  C1*eye(K)         zeros(K,S-K);
         zeros(S-K,K)  C2*eye(S-K)] * U' * Itau;
     
%% 导入待记忆的模式
Ai = [-0.7; -0.6; 0.6];
y0 = Ai;

%% 迭代计算
for i = 1:5
    for j = 1:size(y0,1)
        y{i}(j,:) = satlins(w(j,:)*y0 + b(j));
    end
    y0 = y{i};
end
y{1}

There are a total of two sets of data, if necessary, you can contact by private message.

Guess you like

Origin blog.csdn.net/Allen1862105/article/details/129460945
Recommended