-
大小: 21.83MB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2023-06-14
- 語言: Matlab
- 標(biāo)簽: 深度學(xué)習(xí)??數(shù)學(xué)建模??視頻處理??
資源簡介
是博客https://blog.csdn.net/qq_35759272/article/details/109252165(2020研究生數(shù)學(xué)建模——大霧能見度估計與預(yù)測(E題)AlexNet深度網(wǎng)絡(luò)解法)文章對應(yīng)的程序。需要配合我之前上傳的視頻截圖文件,可以在我的上傳文件里下載,注意:此程序是在MATLAB2020a上運行,低版本的MATLAB運行不了,安裝完MATALB2020a之后要安裝alexnet.mlpkginstall文件,具體怎么安裝看博客鏈接
代碼片段和文件信息
%%?本程序由博客凌青羽:https://blog.csdn.net/qq_35759272/article/details/109252165改寫
%%?加載數(shù)據(jù)集
unzip(‘MerchData.zip‘)
%unzip?提取zip文件的內(nèi)容
%Location?=?‘E:\Image_Set‘;%使用自己的數(shù)據(jù)集進行訓(xùn)練
imds?=?imageDatastore(‘MerchData‘?...%若使用自己的數(shù)據(jù)集,將其改為Location
????‘IncludeSubfolders‘true?...
????‘LabelSource‘‘foldernames‘);
%imageDatastore?圖像數(shù)據(jù)的數(shù)據(jù)存儲???/...續(xù)行
%???imds?=?imageDatastore(locationNameValue)
%???location-要包括在數(shù)據(jù)存儲中的文件或文件夾
%???Name-相對組參數(shù)
%?????‘IncludeSubfolders‘-子文件夾包含標(biāo)記
%??????????ture?or?false??|?0?or?1??(逗號隔開)
%??????????————指定ture可包含每個文件夾中的所有文件和子文件夾,指定false則僅包含每個文件夾中的文件
%??????‘FileExtensions‘-圖像文件擴展名
%??????‘AlternateFileSystemRoots‘-備用文件系統(tǒng)根路徑
%???????‘LabelSource‘-提供標(biāo)簽數(shù)據(jù)的源
%?????????????指定為以逗號分隔的對組,如果指定了‘none‘,則Labels屬性為空。如果指定了‘foldernames‘將根據(jù)文件夾名稱分配標(biāo)簽并
%??????????????存儲在Labels屬性中?
[imdsTrainimdsValidation]?=?splitEachLabel(imds0.7‘randomized‘);%隨機拆分imds中的文件,前70%放入imdsTrain中,剩余30%翻入imdsValidation中
%??splitEachLabel-按比例拆分ImageDatastor標(biāo)簽
%??[imds1imds2]?=?splitEachLabel(imdsp)
%???????可將imds中的圖像文件拆分為兩個新的數(shù)據(jù)存儲,imds1和imds2.新的數(shù)據(jù)存儲imds1包含每個標(biāo)簽前百分之p個文件,imds2中包含剩余的文件
?
numTrainImages?=?numel(imdsTrain.Labels);%numel數(shù)組中的元素數(shù)目
%隨機顯示數(shù)據(jù)集中的圖像
%?idx?=?randperm(numTrainImages16);
%?%?randperm——隨機置換
%?%???p?=?randperm(n,k)返回行向量,其中包含1到n自檢隨機選擇的k個唯一整數(shù)
%?figure
%?for?i?=?1:16
%?????subplot(44i)
%?????I?=?readimage(imdsTrainidx(i));
%?%?????img?=?readimage(imds,i)——從數(shù)據(jù)存儲imds中讀取地i個圖像文件并返回圖像數(shù)據(jù)img
%?????imshow(I)
%?end
%%?加載預(yù)訓(xùn)練網(wǎng)絡(luò)
Alexnet_Train?=?alexnet;
%net.layers???%展示這個網(wǎng)絡(luò)架構(gòu),這個網(wǎng)絡(luò)有5個卷積層和3個全連接層
inputSize?=?Alexnet_Train.layers(1).InputSize;??
%??第一層是圖像輸入層,要求輸入圖像的尺寸為227*227*3?這里的3是顏色通道的數(shù)字
%%?替換最后三層
layersTransfer?=?Alexnet_Train.layers(1:end-3);
%?Extract?all?layers?exceptthe?last?three?from?the?pretrained?network
%?預(yù)處理網(wǎng)絡(luò)的最后三層被配置為1000個類。這三層必須針對新的分類問題進行調(diào)整
numClasses?=?numel(categories(imdsTrain.Labels));%數(shù)據(jù)集中類的數(shù)目
layers?=?[
????layersTransfer
????fullyConnectedlayer(numClasses‘WeightLearnRateFactor‘20‘BiasLearnRateFactor‘20)
????softmaxlayer
????classificationlayer];
%????Transfer?the?layers?to?the?new?classification?task?by?replacing?the?last?three?layers?with?a?fully?connected?layer
%a?softmax?layer?and?a?classification?output?layer.?Specify?the?options?of?the?new?fully?connected?layer?according?
%to?the?new?data.?Set?the?fully?connected?layer?to?have?the?same?size?as?the?number?of?classes?in?the?new?data.?
%To?learn?faster?in?the?new?layers?than?in?the?transferred?layers?increase?the?WeightLearnRateFactor?and?
%BiasLearnRateFactor?values?of?the?fully?connected?layer.
%?????通過將最后三個圖層替換為完全連接圖層,softmax圖層和分類輸出圖層,將圖層轉(zhuǎn)移到新的分類任務(wù)。根據(jù)新的數(shù)據(jù)指定新的完全連接層的
%?選項。將完全連接層設(shè)置為與新數(shù)據(jù)中的類數(shù)大小相同。要在新層中比傳輸層更快的學(xué)習(xí),增加完全連接層的WeightLearnRateFactor?和?
%?BiasLearnRateFactor的值
%%?本程序由博客凌青羽:https://blog.csdn.net/qq_35759272/article/details/109252165改寫
%%?訓(xùn)練網(wǎng)絡(luò)
%用于數(shù)據(jù)增強,增加數(shù)據(jù)量
%????The?network?requires?input?images?of?size?227-by-227-by-3?but?the?images?in?the?image?datastores?have?different?sizes.?
%?Use?an?augmented?image?datastore?t
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????15422??2020-09-22?19:57??2020研究生數(shù)學(xué)建模——大霧能見度估計與預(yù)測(E題)AlexNet深度網(wǎng)絡(luò)解法程序(凌青羽)\alexnet.mlpkginstall
?????文件??????12413??2020-10-29?10:00??2020研究生數(shù)學(xué)建模——大霧能見度估計與預(yù)測(E題)AlexNet深度網(wǎng)絡(luò)解法程序(凌青羽)\AlexNet_test.m
?????文件???23449715??2020-09-22?21:42??2020研究生數(shù)學(xué)建模——大霧能見度估計與預(yù)測(E題)AlexNet深度網(wǎng)絡(luò)解法程序(凌青羽)\MerchData.zip
?????目錄??????????0??2020-10-29?10:03??2020研究生數(shù)學(xué)建模——大霧能見度估計與預(yù)測(E題)AlexNet深度網(wǎng)絡(luò)解法程序(凌青羽)
-----------?---------??----------?-----??----
?????????????23477550????????????????????4
評論
共有 條評論