资源简介
用matlab神经网络实现数字0-9的识别,包含噪声和斜体的识别,一共用了三种分块方式

代码片段和文件信息
% LOGSIG function is used in hidden layer;
% PURELIN function is used in the output layer
function[convergenceave_errmax_errresultvwThres_bThres_c]=bp_logsig_lin(inputsoutputsNum_hidAlphaBetaerrmax_stop)
% Backpropagation Algorithm
% Input arguments:
% inputs - a matrix of dimension (samples x n)
% outputs - a matrix of dimension (samples x q)
% Num_hid - number of hidden units (i.e. p)
% Alpha - learning rate between the output and hidden layer
% Beta - learning rate between the input and hidden layer
% err - error for the stopping criterion
% max_stop - maximum number of iterations
% Output arguments:
% convergence - a vector of dimension 1 x max_stop containing the ave_error at each iteration
% ave_err - average error at the output
% max_err - maximum error at the output
% result - a matrix of dimension (samples x 3)
% The three columns give inputs desired outputs and NN outputs
% First the dimension of the input and output matrices are checked
disp(‘Demo on Backpropagation Algorithm by Dr. G. Pang‘)
[Num_examplesNum_in]=size(inputs);
[tmpNum_out]=size(outputs);
if (Num_examples ~= tmp)
disp(‘Number of input-output training examples not the same‘)end
% Initize the convergence vector
convergence = zeros(1max_stop);
% Initial weights are randomly selectly from [-0.50.5];
% The “rand“ command gives a value between 0 and 1.
k=0.5;
v=rand(Num_inNum_hid)-k*ones(Num_inNum_hid);
w=rand(Num_hidNum_out)-k*ones(Num_hidNum_out);
Thres_b =rand(1Num_hid)-k*ones(1Num_hid);
Thres_c =rand(1Num_out)-k*ones(1Num_out);
% This is the main loop of the program
iterations = 0; max_err = 1000;
% Continue the WHILE loop ONLY if BOTH criteria are true. That is
% (a) the max_err is larger than the desired max. error amount AND
% (b) the number of interations is still less than the maximum number of iterations
while (max_err >= err & iterations < max_stop)
iterations = iterations + 1;
for N=1:Num_examples
% a and ck is the N-th pair of training example
a = inputs(N:);
ck = outputs(N:);
% Get all the b‘s (outputs from the hidden layer) LOGSIG function
for i=1:Num_hid
b(1i)=logsig( a*v(:i)+Thres_b(i));
end
% Get all the c‘s (outputs from the output layer) PURELIN function
for j=1:Num_out
c(1j) = b*w(:j)+Thres_c(j);
end
% Compute the error at the outputs (d)
for j=1:Num_out
d(1j) = ck(j)-c(j);
end
% Computer the e‘s (the errors at the hidden layer relative to each d
for i = 1:Num_hid
e(1i) = b(i)*(1-b(i))*(w(i:)*d‘);
end
% Adjust the weights between the hidden and output layers
for i = 1:Num_hid
for j = 1:Num_out
w(ij) = w(ij) + Alpha*b(i)*d(j);
end
end
% Adjust the thresholds at the output layer
for j = 1:Num_out
Thres_c(j) = Thres_c(j) + Alpha*d(j);
end
% Adjust the weights between the hidden and input layers
for i = 1:Num_in
for j = 1:Num_hid
v(ij) = v(ij) + Beta*a(i)*e(j);
end
end
% Adjust the thresholds
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4595 2017-02-24 11:50 bp_logsig_lin.m
目录 0 2017-01-13 14:38 Class03b ANN assignment\
目录 0 2017-03-01 22:40 Class03b ANN assignment\numS\
目录 0 2017-03-01 22:26 Class03b ANN assignment\numSnoise\
文件 694 2005-09-23 01:03 Class03b ANN assignment\numSnoise\0numSn.bmp
文件 694 2005-09-25 15:27 Class03b ANN assignment\numSnoise\1numSn.bmp
文件 694 2005-09-23 01:05 Class03b ANN assignment\numSnoise\2numSn.bmp
文件 694 2005-09-23 01:06 Class03b ANN assignment\numSnoise\3numSn.bmp
文件 694 2005-09-23 01:07 Class03b ANN assignment\numSnoise\4numSn.bmp
文件 694 2005-09-23 01:07 Class03b ANN assignment\numSnoise\5numSn.bmp
文件 694 2005-09-23 01:08 Class03b ANN assignment\numSnoise\6numSn.bmp
文件 694 2005-09-23 01:11 Class03b ANN assignment\numSnoise\7numSn.bmp
文件 694 2005-09-23 01:11 Class03b ANN assignment\numSnoise\8numSn.bmp
文件 694 2005-09-23 01:02 Class03b ANN assignment\numSnoise\9numSn.bmp
文件 5601 2017-03-01 15:06 Class03b ANN assignment\numSnoise\A1.mat
文件 6589 2017-03-01 15:06 Class03b ANN assignment\numSnoise\A2.mat
文件 8377 2017-03-01 15:06 Class03b ANN assignment\numSnoise\A3.mat
文件 11562 2017-03-01 15:06 Class03b ANN assignment\numSnoise\A4.mat
文件 14434 2017-03-01 15:06 Class03b ANN assignment\numSnoise\A5.mat
文件 23879 2017-03-01 15:06 Class03b ANN assignment\numSnoise\A6.mat
文件 7057 2017-03-01 15:56 Class03b ANN assignment\numSnoise\Aa1.mat
文件 9242 2017-03-01 15:56 Class03b ANN assignment\numSnoise\Aa2.mat
文件 12950 2017-03-01 15:56 Class03b ANN assignment\numSnoise\Aa3.mat
文件 20411 2017-03-01 15:56 Class03b ANN assignment\numSnoise\Aa4.mat
文件 27853 2017-03-01 15:56 Class03b ANN assignment\numSnoise\Aa5.mat
文件 50471 2017-03-01 15:56 Class03b ANN assignment\numSnoise\Aa6.mat
文件 11429 2017-03-01 22:22 Class03b ANN assignment\numSnoise\C1.mat
文件 21386 2017-03-01 22:22 Class03b ANN assignment\numSnoise\C2.mat
文件 36590 2017-03-01 22:22 Class03b ANN assignment\numSnoise\C3.mat
文件 67607 2017-03-01 22:22 Class03b ANN assignment\numSnoise\C4.mat
文件 98392 2017-03-01 22:22 Class03b ANN assignment\numSnoise\C5.mat
............此处省略136个文件信息
- 上一篇:CBIR-matlab
- 下一篇:印章识别matlab代码
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论