ディープラーニングに使用する画像のサイズについて
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
大空
am 25 Jun. 2022
Bearbeitet: Kojiro Saito
am 26 Jun. 2022
ネットから拾ってきた画像を学習さえたいのですが
%% 画像読み込み
imds = imageDatastore('catdog','IncludeSubfolders',true,'LabelSource','foldernames');
labelCount = countEachLabel(imds)
%% データで振り分ける
rateTrainFiles = 0.6;
[imdsTrain,imdsValidation] = splitEachLabel(imds,rateTrainFiles,'randomize');
%%画像サイズ
layers = [256,256,3];
aug_imdsTrain = augmentedImageDatastore(layers,imdsTrain);
aug_imdsValidation = augmentedImageDatastore(layers,imdsValidation);
options = trainingOptions('sgdm', ...
'InitialLearnRate',0.01,...
'MaxEpochs',4,...
'Shuffle','every-epoch',...
'ValidationData',imdsValidation,...
'VerboseFrequency',30,...
'Verbose',false, ...
'Plots','training-progress');
net=trainNetwork(imdsTrain,layers,options);
これでエラーが学習イメージサイズが違いますってでてしまいました
どこを直せばよろしいでしょうか?
0 Kommentare
Akzeptierte Antwort
Atsushi Ueno
am 25 Jun. 2022
aug_imdsTrain = augmentedImageDatastore([256,256,3],imdsTrain);
は良いのですが、
net=trainNetwork(imdsTrain,[256,256,3],options);
は求められているネットワーク層の情報が与えられていません。2番目の引数layersは、学習させるニューラルネットワークのネットワーク層を指定する為の引数で、画像サイズではありません。
>どこを直せばよろしいでしょうか?
例えば以下の様にすればエラーは解消すると思います。
layers_for_trainNetwork = [imageInputLayer([28 28 1]) convolution2dLayer(5,20) reluLayer maxPooling2dLayer(2,'Stride',2) fullyConnectedLayer(10) softmaxLayer classificationLayer];
options = ...% optionsは修正不要
net=trainNetwork(imdsTrain,layers_for_trainNetwork,options);
2 Kommentare
Atsushi Ueno
am 25 Jun. 2022
すいません。それでしたら下記の様にすれば良いです。
layers_for_trainNetwork = [imageInputLayer([800 1200 3]) convolution2dLayer(5,20) reluLayer maxPooling2dLayer(2,'Stride',2) fullyConnectedLayer(10) softmaxLayer classificationLayer];
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu イメージを使用した深層学習 finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!