フィルターのクリア

Invalid training data. For image, sequence-to-label, and feature classification tasks, responses must be categorical.

4 ビュー (過去 30 日間)
Please help me out with this
Thanks in Advance
Below is the code
clc;
clear all;
imds = imageDatastore('/MATLAB Drive/HGG','IncludeSubfolders',true,'FileExtensions','.nii','LabelSource','foldernames');
imds.ReadFcn = @niftiread;
imds1 = transform(imds,@(x)imgaussfilt(x,2));
patchds = randomPatchExtractionDatastore(imds,imds1,[100 100]);
data = read(patchds);
layers = [
image3dInputLayer([240 240 155 1],"Name","image3dinput")
convolution3dLayer([3 3 3],32,"Name","conv3d_1","Padding","same")
reluLayer("Name","relu1")
batchNormalizationLayer("Name","batchnorm_1")
maxPooling3dLayer([5 5 5],"Name","maxpool3d_1","Padding","same")
convolution3dLayer([3 3 3],32,"Name","conv3d_2","Padding","same")
reluLayer("Name","relu2")
batchNormalizationLayer("Name","batchnorm_2")
maxPooling3dLayer([5 5 5],"Name","maxpool3d_2","Padding","same")
convolution3dLayer([3 3 3],32,"Name","conv3d_3","Padding","same")
reluLayer("Name","relu3")
convolution3dLayer([3 3 3],32,"Name","conv3d_4","Padding","same")
reluLayer("Name","relu4")
convolution3dLayer([3 3 3],32,"Name","conv3d_5","Padding","same")
reluLayer("Name","relu5")
maxPooling3dLayer([5 5 5],"Name","maxpool3d_3","Padding","same")
fullyConnectedLayer(2,"Name","fc_2")
reluLayer("Name","relu6")
dropoutLayer(0.5,"Name","drop6")
fullyConnectedLayer(10,"Name","fc_1")
reluLayer("Name","relu7")
dropoutLayer(0.5,"Name","drop7")
fullyConnectedLayer(2,"Name","fc_3")
softmaxLayer("Name","prob")
classificationLayer("Name","classoutput")];
options = trainingOptions('sgdm','MiniBatchSize',2,'MaxEpochs',2,'InitialLearnRate',1e-4,'Shuffle','every-epoch','Verbose',false,'Plots','training-progress');
net = trainNetwork(patchds,layers,options);
Error is
Error using trainNetwork (line 184)
Invalid training data. For image, sequence-to-label, and feature classification tasks, responses must be categorical.
Error in Ex (line 36)
net = trainNetwork(patchds,layers,options);

採用された回答

yanqi liu
yanqi liu 2021 年 12 月 1 日
編集済み: yanqi liu 2021 年 12 月 1 日
yes,sir,please use the follow code to test
imds1 = transform(imds,@(x)imgaussfilt(x,2));
%change to
imds1 = imageDatastore('MerchData','IncludeSubfolders',true,'LabelSource','foldernames','ReadFcn',@myreadfcn);
%and the function is
function J = myreadfcn(filename)
I = niftiread(filename);
J = imgaussfilt(I,2);
end
  2 件のコメント
Max Walliam
Max Walliam 2021 年 12 月 1 日
Files must be a valid string scalar, character vector, cell array of character vectors, string array, or a
matlab.io.datastore.FileSet.
Walter Roberson
Walter Roberson 2021 年 12 月 2 日
Please show your current imageDatastore() call

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by