资源简介
用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代码
相关资源
- Pattern Recognition and Machine Learning(高清
- MATLAB 编程 第二版 Stephen J. Chapman 著
- 均值滤波和FFT频谱分析Matlab代码
- 《MATLAB扩展编程》代码
- HDB3码、AMI码的MATLAB实现
- 3点GPS定位MATLAB仿真
- MATLAB数字信号处理85个实用案例精讲入
- matlab从入门到精通pdf94795
- 基于BP神经网络的语音情感识别系统
- 欧拉放大论文及matlab代码
- 跳一跳辅助_matlab版本
- 全面详解LTE MATLAB建模、仿真与实现
- MIMO-OFDM无线通信技术及MATLAB实现_孙锴
- MATLAB Programming for Engineers 4th - Chapman
- matlab 各种谱分析对比
- 分数阶chen混沌matlab程序
- 基于粒子群算法的非合作博弈的matl
- MATLAB车流仿真 包括跟驰、延误
- matlab空间桁架计算程序
- 基于MATLAB的图像特征点匹配和筛选
- DMA-TVP-FAVAR
- GPS信号的码捕获matlab代码.7z
- 一维光子晶体MATLAB仿真代码吸收率折
- newmark法源程序
- 传统关联成像、计算鬼成像matlab
- pri传统分选算法
- 摆动滚子推杆盘形凸轮设计
- 医学图像重建作业matlab源码
- Matlab实现混沌系统的控制
- 检测疲劳驾驶
评论
共有 条评论