-
大小: 1KB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2021-05-28
- 語(yǔ)言: 其他
- 標(biāo)簽: BP神經(jīng)網(wǎng)??圖像識(shí)別??
資源簡(jiǎn)介
BP神經(jīng)網(wǎng)絡(luò)實(shí)現(xiàn)圖像識(shí)別(BP神經(jīng)網(wǎng)絡(luò)實(shí)現(xiàn)圖像識(shí)別,批量輸入圖像得到識(shí)別結(jié)果。)

代碼片段和文件信息
%?clear?all;close?all;
%?%讀取訓(xùn)練數(shù)據(jù)
%?[f1f2f3f4class]?=?textread(‘floTrainData.txt‘??‘%f%f%f%f%f‘150);
tic;
clc;clear?all;close?all;
%?%?listing=dir(‘F:\桌面\ELM數(shù)據(jù)集\1(*).jpg‘);
%?Files1?=?dir(fullfile(‘C:\Users\Administrator\Desktop\AUV聲吶論文\BP\數(shù)據(jù)\正\‘‘*.jpg‘));
%?Length?=?length(Files1);
%?for?i=1:?Length
%??I?=?imread(strcat(‘C:\Users\Administrator\Desktop\AUV聲吶論文\BP\數(shù)據(jù)\正\‘Files1(i).name));
%?I=imresize(I[100?100]);
%?x1(:i)=reshape(I100*1001);
%?end
%?Files2?=?dir(fullfile(‘C:\Users\Administrator\Desktop\AUV聲吶論文\BP\數(shù)據(jù)\負(fù)\‘‘*.jpg‘));
%?Length?=?length(Files2);
%?for?i=1:?Length
%??I?=?imread(strcat(‘C:\Users\Administrator\Desktop\AUV聲吶論文\BP\數(shù)據(jù)\負(fù)\‘Files2(i).name));
%?I=imresize(I[100?100]);
%?x2(:i)=reshape(I100*1001);
%?end
%?t=ones(1Length);
%?jzcs_9ping40=cat(1tx);
%---------------------------------------------------
%輸入輸出數(shù)據(jù)
%---------------------------------------------------
load(‘F:\程序\膠州灣識(shí)別\程序\BPcode\JZtest_70pingcd_jhbw_bp.mat‘)
load(‘F:\程序\膠州灣識(shí)別\程序\BPcode\JZtrain_70pingcd_jhbw_bp.mat‘)
x=JZtrain_70pingcd_jhbw_bp(2:end:);
label=JZtrain_70pingcd_jhbw_bp(1:);
x_test=JZtest_70pingcd_jhbw_bp(2:end:);
label_test=JZtest_70pingcd_jhbw_bp(1:);
%?x=[x1?x2];
%?label=[1?1?1?1?1?1?1?2?2?2?2?2?2?2];
%?x=double(x);
%?x_test=x(:6:9);
%?label_test=label(:6:9);
%特征值歸一化
[inputminImaxI]?=?premnmx(x)?;
%構(gòu)造輸出矩陣
class=label‘;
s?=?length(?class)?;
output?=?zeros(?s??1?)?;%改標(biāo)簽類型
for?i?=?1?:?s?
???output(?i??class(?i1?))?=?1?;
end
%創(chuàng)建神經(jīng)網(wǎng)絡(luò)
net?=?newff(?minmax(input)??[10?2]??{?‘logsig‘?‘purelin‘?}??‘traingdx‘?)?;?
%設(shè)置訓(xùn)練參數(shù)
net.trainparam.show?=?50?;
net.trainparam.epochs?=?500?;
net.trainparam.goal?=?0.01?;
net.trainParam.lr?=?0.01?;
%開始訓(xùn)練
net?=?train(?net?input??output‘?)?;
%讀取測(cè)試數(shù)據(jù)
%?[t1?t2?t3?t4?c]?=?textread(‘floTestData.txt‘??‘%f%f%f%f%f‘150);
%測(cè)試數(shù)據(jù)歸一化
testInput?=?tramnmx?(?x_test??minI?maxI?)?;
c=label_test‘;
%仿真
Y?=?sim(?net??testInput?)?
%統(tǒng)計(jì)識(shí)別正確率
[s1??s2]?=?size(?Y?)?;
hitNum?=?0?;
for?i?=?1?:?s2
????[m??Index]?=?max(?Y(?:???i?)?)?;
????if(?Index??==?c(i)???)?
????????hitNum?=?hitNum?+?1?;?
????end
end
sprintf(‘識(shí)別率是?%3.3f%%‘100?*?hitNum?/?s2?)
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????2318??2017-03-17?19:56??BP.m
- 上一篇:用回溯法解決TSP問題
- 下一篇:中國(guó)電信筆試題資料通信類
評(píng)論
共有 條評(píng)論