Data format error with training a ResNet for semantic segmentation
Show older comments
I am trying to train a ResNet for the purpose of a pixel classification problem with two classes. The data consists of 256x256 RGB images, groundtruth is 256x256 Categorical. However there seems to be a conflict of data formats in regard to the final softmax layer of the network. Here is an excerpt from my code along with the error message.
input_size = [256 256 3];
numClasses = 2;
resNet = resnetNetwork(input_size, numClasses);
options = trainingOptions('adam', ...
'InitialLearnRate',1e-3, ...
'MaxEpochs',30, ...
'MiniBatchSize',64, ...
'Metrics','accuracy', ...
'Plots','training-progress', ...
'ValidationFrequency',25, ...
'ValidationData',validationData);
trainedResNetGreen = trainnet(trainingData,resNet,@(Y,T) modelLoss(Y,T,classWeights),options);
Error using trainnet (line 46)
Error forming mini-batch of targets for network output "softmax". Data interpreted with format "BC". To specify a different format,
use the TargetDataFormats option.
Error in ResNetGreen (line 37)
trainedLCUnetGreen = trainnet(trainingData,resNet,@(Y,T) modelLoss(Y,T,classWeights),options);
Caused by:
Batch dimension of datastore must match the format batch dimension (1).
I already tried to specify the Target Data Format as "SSBC" which corresponds to "Spatial, Spatial, Batch, Channel" but it did not fix the problem. Am I missing something?
Accepted Answer
More Answers (0)
Categories
Find more on Deep Learning Toolbox 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!