VGG19 net Error

4 visualizzazioni (ultimi 30 giorni)
mohd akmal masud
mohd akmal masud il 13 Lug 2022
Commentato: mohd akmal masud il 13 Lug 2022
Dear all, I was run the VGG19 using apps designer. But I got error.
**The workspace of data as attached. (matlab.mat)
Anyone can help me?
Because actually I dont understand what fullyconnected function
clc
clear all
close all
%testDataimages
DATASetDir = fullfile('C:\Users\Akmal\Desktop\NEW 3D U NET');
IMAGEDir = fullfile(DATASetDir,'ImagesTr');
volReader = @(x) matRead(x);
volds = imageDatastore(IMAGEDir, ...
'FileExtensions','.mat','ReadFcn',volReader);
% labelReader = @(x) matread(x);
matFileDir = fullfile('C:\Users\Akmal\Desktop\NEW 3D U NET\LabelsTr');
classNames = ["background", "tumor"];
pixelLabelID = [0 1];
% pxds = (LabelDirr,classNames,pixelLabelID, ...
% 'FileExtensions','.mat','ReadFcn',labelReader);
pxds = pixelLabelDatastore(matFileDir,classNames,pixelLabelID, ...
'FileExtensions','.mat','ReadFcn',@matRead);
volume = preview(volds);
label = preview(pxds);
up1 = uipanel;
h = labelvolshow(label, volume, 'Parent', up1);
h.CameraPosition = [4 2 -3.5];
h.LabelVisibility(1) = 0;
h.VolumeThreshold = 0.5;
volumeViewer(volume, label)
patchSize = [128 128 64];
patchPerImage = 16;
miniBatchSize = 8;
patchds = randomPatchExtractionDatastore(volds,pxds,patchSize, ...
'PatchesPerImage',patchPerImage);
patchds.MiniBatchSize = miniBatchSize;
dsTrain = transform(patchds,@augment3dPatch);
volLocVal = fullfile('C:\Users\Akmal\Desktop\NEW 3D U NET\imagesVal');
voldsVal = imageDatastore(volLocVal, ...
'FileExtensions','.mat','ReadFcn',volReader);
lblLocVal = fullfile('C:\Users\Akmal\Desktop\NEW 3D U NET\labelsVal');
pxdsVal = pixelLabelDatastore(lblLocVal,classNames,pixelLabelID, ...
'FileExtensions','.mat','ReadFcn',volReader);
dsVal = randomPatchExtractionDatastore(voldsVal,pxdsVal,patchSize, ...
'PatchesPerImage',patchPerImage);
dsVal.MiniBatchSize = miniBatchSize;
layers = [
image3dInputLayer([128 128 64 1],"Name","image3dinput")
convolution3dLayer([3 3 3],32,"Name","conv3d_1","Padding","same")
reluLayer("Name","relu_1")
convolution3dLayer([3 3 3],32,"Name","conv3d_2","Padding","same")
reluLayer("Name","relu_2")
maxPooling3dLayer([5 5 5],"Name","maxpool3d_1","Padding","same")
convolution3dLayer([3 3 3],32,"Name","conv3d_3","Padding","same")
reluLayer("Name","relu_3")
convolution3dLayer([3 3 3],32,"Name","conv3d_4","Padding","same")
reluLayer("Name","relu_4")
maxPooling3dLayer([5 5 5],"Name","maxpool3d_2","Padding","same")
convolution3dLayer([3 3 3],32,"Name","conv3d_5","Padding","same")
reluLayer("Name","relu_5")
convolution3dLayer([3 3 3],32,"Name","conv3d_6","Padding","same")
reluLayer("Name","relu_6")
convolution3dLayer([3 3 3],32,"Name","conv3d_7","Padding","same")
reluLayer("Name","relu_7")
convolution3dLayer([3 3 3],32,"Name","conv3d_8","Padding","same")
reluLayer("Name","relu_8")
maxPooling3dLayer([5 5 5],"Name","maxpool3d_3","Padding","same")
convolution3dLayer([3 3 3],32,"Name","conv3d_9","Padding","same")
reluLayer("Name","relu_9")
convolution3dLayer([3 3 3],32,"Name","conv3d_10","Padding","same")
reluLayer("Name","relu_10")
convolution3dLayer([3 3 3],32,"Name","conv3d_11","Padding","same")
reluLayer("Name","relu_11")
convolution3dLayer([3 3 3],32,"Name","conv3d_12","Padding","same")
reluLayer("Name","relu_12")
maxPooling3dLayer([5 5 5],"Name","maxpool3d_4","Padding","same")
convolution3dLayer([3 3 3],32,"Name","conv3d_13","Padding","same")
reluLayer("Name","relu_13")
convolution3dLayer([3 3 3],32,"Name","conv3d_14","Padding","same")
reluLayer("Name","relu_14")
convolution3dLayer([3 3 3],32,"Name","conv3d_15","Padding","same")
reluLayer("Name","relu_15")
convolution3dLayer([3 3 3],32,"Name","conv3d_16","Padding","same")
reluLayer("Name","relu_16")
maxPooling3dLayer([5 5 5],"Name","maxpool3d_5","Padding","same")
fullyConnectedLayer(10,"Name","fc_3")
reluLayer("Name","relu_18")
dropoutLayer(0.5,"Name","dropout_1")
fullyConnectedLayer(10,"Name","fc_2")
reluLayer("Name","relu_17")
dropoutLayer(0.5,"Name","dropout_2")
fullyConnectedLayer(10,"Name","fc_1")
softmaxLayer("Name","softmax")
pixelClassificationLayer("Name","pixel-class")];
plot(layerGraph(layers));
ERROR

Risposta accettata

Walter Roberson
Walter Roberson il 13 Lug 2022
classNames = ["background", "tumor"];
That is only two classes
fullyConnectedLayer(10,"Name","fc_1")
You are asking for 10 connections on the output layer, but 10 connections would be what you would use for training 10 classes. The number of connections on the output layer should be the same as the number of classes.
  1 Commento
mohd akmal masud
mohd akmal masud il 13 Lug 2022
means that if my number of classes only 2, so my fullyConnectedLayer like below
fullyConnectedLayer(10,"Name","fc_1")
then only 2 connections layer only?

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by