当前位置:网站首页>【数字识别】基于Hopfield神经网络识别0-9数字附Matlab代码
【数字识别】基于Hopfield神经网络识别0-9数字附Matlab代码
2022-07-27 20:19:00 【Matlab科研工作室】
1 内容介绍
自1943年 McCulloch和 Pitts首次提出了人工神经元模型以来,新的神经元模型及其组成的神经网络不断被提出,已成为目前非线性科学和计算智能研究的一个主要研究方向。其中,神经网络图像识别技术随着当代计算机技术、图像处理、人工智能、模式识别理论等快速发展,是传统图像识别方法与神经网络算法相融合的一种图像识别方法[3-4]。利用神经网络进行字符识别在计算机识别领域占有越来越重要的地位,并且广泛应用于雾天或者夜晚的交通车牌识别、机器视觉等实际应用领域。近些年来,利用 Hopfield神经网络识别噪声字符、汽车牌照字符等实例表明这种方法识别率高、鲁 棒 性 好 且 具 有 很 好 的 实 用 性:例 如 朱 献 文[5]研究 了 基 于 遗 传 算 法Hopfield神经网络的字符识别方法;魏武[6]等人对车牌字符识别模板匹配的神经网络方法进行改进;丘敏[7]等人在汽车牌照字符识别的应用中将 Hopfield和 BP网络结合使用提高了识别率;Tatem[8]等人利用了 Hopfield神经网络识别遥感图像中的土地覆盖目标。以上关于字符识别的研究都把噪声作为有害因素,专注于噪声的消除,而忽视了噪声的有益作用,实际上噪声可以增强神经元信息处理能力,即神经科学中的随机共振现象[9-11]。最近,Hopfield神经网络的随机共振现象研究已取得了重大进展,如 Katada[9]等人研究了 Hopfield网络中随机共振现象,并扩展到包含156个神经元的网络中;Pinamonti[10]等人研究了复杂网络中多峰随机共振的重要特征;Nishimura[11]等人研究了由3个神经元构成的神经网络中随机共振型反馈,将它作为有效的混沌动力学的双势阱模型。本文主要利用离散 Hopfield神经网络识别手写数字,将被识别的图像二进制编码变成串行编码,根据信号在稳态间回环往复的规律输入到 Hopfield神经元网络中,不仅研究输入信号幅值调制,码间间隔以及神经元耦合个数对于网络识别图像的影响,还研究了传输过程中噪声强度与图像识别误码率的非线性特性Hopfield神经网络是由 Hopfield[12-13]于1982年首先提出的一种单层的、输出为二值的全连接型的反馈神经 网络。离散 Hopfield神经网络只有一个神经元层,第0层仅作为网络的输入,并无计算功能,而第1层是神经元 层,用于对输入数据和权系数的乘积求累加和,并经非线性激活函数处理后产生输出信息。该网络模拟生物神经 网络的记忆机制,具有联想记忆的功能。3个神经元构成的离散 Hopfield神经网络可以用加权无向图表示,如图 1所示。 图1 离散型 Hopfield神经网络结构 Fig.1 Architectureofdiscreteneuralnetworks 从图1可以看出神经元间是相互联系的,并且网 络中每一个神经元的输出都反馈到其他神经元上,每 条边上权值表示有关神经元之间的连接强度,每个节 点代表一个神经元且附有一个阈值,当某神经元所受 到的刺激超过其阈值时,神经元就处于激活状态,否则 神经元就处于静息状态。我们取神经元激活函数[9]为



2 仿真代码
function out1 = newhop(varargin)%NEWHOP Design a Hopfield recurrent network.%% Hopfield networks perform a kind of pattern recall. They are included% primarily for historical purposes. For more robust pattern recognition% use <a href="matlab:doc patternnet">patternnet</a>.%% <a href="matlab:doc newhop">newhop</a>(T) takes an RxQ matrix of Q target vectors T with element% values of +1 or -1, and returns a new Hopfield recurrent neural% network with stable points at the vectors in T.%% Here a Hopfield network with two three-element stable points is% designed and simulated.%% T = [-1 -1 1; 1 -1 1]';% net = <a href="matlab:doc newhop">newhop</a>(T);% Ai = T;% [Y,Pf,Af] = net(2,[],Ai)%% 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] = 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.%% See also SIM, SATLINS.% Mark Beale, 11-31-97% Copyright 1992-2011 The MathWorks, Inc.%% =======================================================% BOILERPLATE_START% This code is the same for all Network Functions.persistent INFO;if isempty(INFO), INFO = get_info; endif (nargin > 0) && ischar(varargin{1}) ...&& ~strcmpi(varargin{1},'hardlim') && ~strcmpi(varargin{1},'hardlims')code = varargin{1};switch codecase 'info',out1 = INFO;case 'check_param'err = check_param(varargin{2});if ~isempty(err), nnerr.throw('Args',err); endout1 = err;case 'create'if nargin < 2, error(message('nnet:Args:NotEnough')); endparam = varargin{2};err = nntest.param(INFO.parameters,param);if ~isempty(err), nnerr.throw('Args',err); endout1 = create_network(param);out1.name = INFO.name;otherwise,% Quick info field accesstryout1 = eval(['INFO.' code]);catch %#ok<CTCH>nnerr.throw(['Unrecognized argument: ''' code ''''])endendelse[args,param] = nnparam.extract_param(varargin,INFO.defaultParam);[param,err] = INFO.overrideStructure(param,args);if ~isempty(err), nnerr.throw('Args',err,'Parameters'); endnet = create_network(param);net.name = INFO.name;out1 = init(net);endendfunction v = fcnversionv = 7;end% BOILERPLATE_END%% =======================================================function info = get_infoinfo = nnfcnNetwork(mfilename,'Hopfield Network',fcnversion, ...[ ...nnetParamInfo('targets','Target Data','nntype.data',{1},...'Target output data.'), ...]);endfunction err = check_param(param)err = '';endfunction net = create_network(param)% Formatt = param.targets;if iscell(t), t = cell2mat(t); end% CHECKINGif (~isa(t,'double')) || ~isreal(t) || isempty(t)error(message('nnet:NNData:TargetsNotRealNonEmpty'));end% DIMENSIONS[S,Q] = size(t);% NETWORK PARAMETERS[w,b] = solvehop2(t);% NETWORK ARCHITECTUREnet = network(0,1,[1],[],[1],[1]);% RECURRENT LAYERnet.layers{1}.size = S;net.layers{1}.transferFcn = 'satlins';net.b{1} = b;net.lw{1,1} = w;net.layerWeights{1,1}.delays = 1;end%==========================================================function [w,b] = solvehop2(t)[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:KTP = TP + U(:,k)*U(:,k)';endTM = zeros(S,S);for k=K+1:STM = TM + U(:,k)*U(:,k)';endtau = 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;end%==========================================================
3 运行结果

4 参考文献
[1]王小峰. 基于离散Hopfield神经网络的数字识别研究[J]. 忻州师范学院学报, 2012, 028(002):21-24.
[2]任东红, 林鹏, and 袁清萍. "基于离散Hopfield神经网络的数字模式识别." 现代职业教育 14(2018):1.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
边栏推荐
- Pyqt5 rapid development and practice 4.10 window drawing controls
- Quartus:Instantiation of ‘sdram_ model_ plus‘ failed. The design unit was not found.
- Excel only wants to visualize charts and make data move? Yes, come and watch (with a large number of templates to download)
- Network development socket and UDP, TCP protocols
- 【StoneDB故障诊断】数据库实例crash
- Tips and extensions of graph theory
- Unity 的基础光照
- 2022/4/8考试总结
- 8000字讲透OBSA原理与应用实践
- 51 MCU internal peripherals: real time clock (SPI)
猜你喜欢

干货|语义网、Web3.0、Web3、元宇宙这些概念还傻傻分不清楚?(中)

一篇文章读懂人工神经网络

4 轮拿下字节 Offer,面试题复盘

Cloudcompare & PCL point cloud equally spaced slices

Quartus:Instantiation of ‘sdram_ model_ plus‘ failed. The design unit was not found.

Network development socket and UDP, TCP protocols

Cloud native enthusiast weekly: a complete collection of client go examples

Do you want to be dismissed? Let's take a look at the "exit tips" of programmers

51 MCU internal peripherals: real time clock (SPI)

MySQL的B+Tree索引到底是咋回事?聚簇索引到底是如何长高的?
随机推荐
Cron expression
Gstore weekly gstore source code analysis (V): log tracking of security mechanism
Introduction to the paper | language model for long text under transformer architecture
JVM composition and memory model
2022 review plan of joint provincial election
ADI, Shijian and Junlong technology jointly donated 2.3 million yuan to help fight the epidemic in Hubei
Cloud security daily 220714: Cisco identity service engine found an authentication bypass vulnerability and needs to be upgraded as soon as possible
Introduction to the paper | distributed graph simulation
Harmonyos third operation
2022/6/9 exam summary
2022/3/10 exam summary
51 MCU internal peripherals: real time clock (SPI)
对象创建过程及对象布局
"The faster the code is written, the slower the program runs."
helm chart详解及常用命令:helm template / package / plugin
leetcode-470.用 Rand7() 实现 Rand10()
Eight years of love between me and the message queue
Five network management trends in 2022
你想被开除吗?来看看程序员「离职小技巧」吧
[C language] simulate and implement string functions (Part 1)