エラーの解消方法
13 views (last 30 days)
Show older comments
画像の機械学習を行おうとしたところ入力引数が不足していると出てしまい、どのような入力引数が足りないかが分かりません
clear,close all;
root='C:\Users\meguroLab_student\Desktop\yamashita\jpeg database release';
setDir=fullfile(root,'database release');
imds = imageDatastore(setDir,'FileExtensions',{'.bmp'});
imds=imresize(132,132);
layers = [ ...
image3dInputLayer([132 132 116 3])
fullyConnectedLayer(10)
softmaxLayer
classificationLayer];
options=trainingOptions('sgdm','InitialLearnRate',0.001,'Plots','training-progress');
net = trainNetwork(imds,layers,options);
save('net.mat','net');
エラー内容
エラー: trainNetwork (line 165)
入力引数が不足しています。
エラー: test (line 12)
net = trainNetwork(imds,layers,options);
原因:
エラー: trainNetwork>iParseInputArguments
(line 296)
入力引数が不足しています。
1 Comment
Atsushi Ueno
on 10 Jan 2023
1番目の引数に132を入力すると、1x1のイメージデータと認識されます。2番目の引数は倍率なので、1x1を132倍した132x132の数値行列が出力されます。これをデフォルトのdouble型のままイメージ表示すると真っ白(132.0/1.0)になり、uint8型としてイメージ表示すると灰色(132/255)になります。
im = imresize(132,132); % im はイメージデータストアではなく、1枚のイメージデータ
imshow(uint8(im));
Answers (1)
Atsushi Ueno
on 9 Jan 2023
イメージをネットワークの入力サイズに一致させるにあたって、学習対象イメージのデータ型を下記のいずれかに統一しなければなりません。
- イメージのスタックを表す 4 次元配列
- ImageDatastore
clear,close all;
root='C:\Users\meguroLab_student\Desktop\yamashita\jpeg database release';
setDir=fullfile(root,'database release');
imds = imageDatastore(setDir,'FileExtensions',{'.bmp'});
auimds = augmentedImageDatastore([132 132],imds); % ここを変更 % imds=imresize(132,132);
layers = [ ...
image3dInputLayer([132 132 116 3])
fullyConnectedLayer(10)
softmaxLayer
classificationLayer];
options=trainingOptions('sgdm','InitialLearnRate',0.001,'Plots','training-progress');
net = trainNetwork(auimds,layers,options); % ここをauimdsに変更
save('net.mat','net');
0 Comments
See Also
Categories
Find more on イメージを使用した深層学習 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!