index is out of range for deletion - error while training semantic segmentation network

1 次查看(过去 30 天)
Hi,
I'm having an issue while training a UNET network for semantic segmentation on 3D nifti images.
I'm getting the following error:
>> network = trainNetwork(ds,lgraph,options);
Error using trainNetwork (line 165)
Matrix index is out of range for deletion.
Caused by:
Matrix index is out of range for deletion.
I'm not sure whether I built wrongly the network or that I didn't created the datastore for training as needed (I'm trying to load 3D nifti images in order to train a 2D semantic segmentation of each "slice" of the 3D image).
Could you please assist me with this issue?
below is my code:
%% Create U-Net Network with Custom Encoder-Decoder Depth
imageSize = [512 512 1];
numClasses = 2;
encoderDepth = 5;
lgraph = unetLayers(imageSize,numClasses,'EncoderDepth',encoderDepth);
dataSetDir = fullfile('c:\','Users','ya','Desktop','images_for_matlab_training');
imageDir = fullfile(dataSetDir,'images');
labelDir = fullfile(dataSetDir,'gTruth');
% Create an imageDatastore object to store the training images
imds = imageDatastore(imageDir,'FileExtensions','.gz','ReadFcn',@ReadNifti);
% Create an pixelDatastore object to store the training images
classNames = ["liver","background"];
labelIDs = [255 0];
pxds = pixelLabelDatastore(labelDir,classNames,labelIDs,'FileExtensions','.gz','ReadFcn',@ReadNifti);
% Create a datastore for training the network
ds = pixelLabelImageDatastore(imds,pxds);
% Set training options
options = trainingOptions('sgdm', ...
'InitialLearnRate',1e-3, ...
'MaxEpochs',3, ...
'MiniBatchSize',10, ...
'Plots','training-progress',...
'Verbose',1,...
'Shuffle','once');
% Train the network
network = trainNetwork(ds,lgraph,options);
Thanks!!
  5 个评论
Mario Malic
Mario Malic 2021-3-7
It looks like it's inside your last line. The full error message should show where is the actual error. If error is somewhere within trainNetwork, then maybe your setup is wrong? I do not know anything about Deep Learning, so I can't help you. Verify that your inputs are correct, use debugging to find out where is the error.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by