Training a network using valudationData of pixelwise labeling

1 visualizzazione (ultimi 30 giorni)
Hi, I am trying to train SegNet, based on this guide: semantic segmentation , while monitoring the loss function etc. I would like to use the validationData option to see how fell the model fairs during the training. I am trying to construct my validation data according to the documentation, however it does not appear to accept it. Is it possible to use this kind of validation data?
This is how i create the validationData
% Construct validationData from image datastore.
validIm = readall(imdsValid);
validLabel = readall(pxdsValid);
validationData = cell(1,2);
validationData{1} = cat(4, validIm{:});
validationData{2} = cat(4, validLabel{:});
options = trainingOptions('sgdm', ...
'Momentum', 0.9, ...
'InitialLearnRate', 1e-3, ...
'L2Regularization', 0.0005, ...
'LearnRateSchedule','piecewise',...
'LearnRateDropFactor',0.2,...
'LearnRateDropPeriod',5,...
'MaxEpochs', 200, ...
'MiniBatchSize', 128, ...
'Shuffle', 'every-epoch', ...
'VerboseFrequency', 1, ...
'Plots', 'training-progress', ...
'ValidationData', validationData, ...
'ValidationFrequency', 100);
% Specify the class weights using a |pixelClassificationLayer|.
pxLayer = pixelClassificationLayer('Name','labels','ClassNames', tbl.Name, 'ClassWeights', classWeights)
% Update the SegNet network with the new |pixelClassificationLayer| by
% removing the current |pixelClassificationLayer| and adding the new layer.
% The current |pixelClassificationLayer| is named 'pixelLabels'. Remove it
% using |removeLayers|, add the new one using|addLayers|, and connect the
% new layer to the rest of the network using |connectLayers|.
lgraph = removeLayers(lgraph, 'pixelLabels');
lgraph = addLayers(lgraph, pxLayer);
lgraph = connectLayers(lgraph, 'softmax' ,'labels');
% Data augmentation
augmenter = imageDataAugmenter('RandXTranslation', [-10 10], ...
'RandYTranslation',[-10 10]);
datasource = pixelLabelImageSource(imdsTrain,pxdsTrain, ...
'DataAugmentation',augmenter);
[net, info] = trainNetwork(datasource, lgraph, options);
  4 Commenti
Sahar Zafari
Sahar Zafari il 22 Gen 2018
Modificato: Sahar Zafari il 22 Gen 2018
Hi,
I am having same problem. Could you please make an example how to define validation data in trainingOption for semantic segmentation?.
Here is the error: "Invalid validation data. Y must be a vector of categorical responses."
Thanks
Steve Scott
Steve Scott il 22 Mar 2018
Yes, I am having this problem too, Sahar.
Is the "vector of categorical responses" per-pixel or per-image? Can you get the "vector of categorical responses" from the pixel datastore?

Accedi per commentare.

Risposte (1)

Tony Mackenzie
Tony Mackenzie il 5 Feb 2018
This was not working for me on 2017b but I just downloaded 2018a and tested it out with my test data using:
enddatasourcetrain = pixelLabelImageSource( imdsTrain, pxdsTrain);
datasourcetest = pixelLabelImageSource( imdsTest, pxdsTest);
options = trainingOptions('sgdm', ...
'Momentum', .9, ...
'InitialLearnRate', 1e-2, ...
'MaxEpochs', 100, ...
'MiniBatchSize',8, ...
'Shuffle', 'every-epoch', ...
'VerboseFrequency', 2,...
'Plots','training-progress',...
'LearnRateDropFactor',0.1,...
'ValidationData', datasourcetest, ...
'LearnRateDropPeriod',100);
Now it is working.
  5 Commenti
todd chelsea
todd chelsea il 8 Mag 2019
there is a same question?
Where is the helperDeepLabv3PlusResnet18 m file???
anybody could do me a favor and give the helperDeepLabv3PlusResnet18.m file.
LJ Zhou
LJ Zhou il 25 Mag 2019
Actually, this file has been already in your disk, you may try this path :
C:\Users\Administrator\Documents\MATLAB\Examples\R2019a\deeplearning_shared\SemanticSegmentationUsingDeepLearningExample

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by