Invalid argument name classificationmode name must be targetcategories, mask etc.
While using this code from Complex yolo document in R2023a version
doTraining = true;
if doTraining
iteration = 0;
% Create subplots for the learning rate and mini-batch loss.
fig = figure;
[lossPlotter, learningRatePlotter] = configureTrainingProgressPlotter(fig);
% Custom training loop.
for epoch = 1:maxEpochs
reset(mbqTrain);
shuffle(mbqTrain);
while(hasdata(mbqTrain))
iteration = iteration + 1;
[XTrain,YTrain] = next(mbqTrain);
% Evaluate the model gradients and loss using dlfeval and the
% modelGradients function.
[gradients,state,lossInfo] = dlfeval(@modelGradients,net,XTrain,YTrain,anchorBoxes,penaltyThreshold,networkOutputs);
% Apply L2 regularization.
gradients = dlupdate(@(g,w) g + l2Regularization*w, gradients, net.Learnables);
% Determine the current learning rate value.
currentLR = piecewiseLearningRateWithWarmup(iteration,epoch,learningRate,warmupPeriod,maxEpochs);
% Update the network learnable parameters using the SGDM optimizer.
[net,velocity] = sgdmupdate(net,gradients,velocity,currentLR);
% Update the state parameters of dlnetwork.
net.State = state;
% Display progress.
if mod(iteration,10)==1
displayLossInfo(epoch,iteration,currentLR,lossInfo);
end
% Update training plot with new points.
updatePlots(lossPlotter,learningRatePlotter,iteration,currentLR,lossInfo.totalLoss);
end
end
else
net = mdl.net;
anchorBoxes = mdl.anchorBoxes;
end
% Create a table to hold the bounding boxes, scores, and labels returned by
% the detector.
results = table(‘Size’,[0 3], …
‘VariableTypes’,{‘cell’,’cell’,’cell’}, …
‘VariableNames’,{‘Boxes’,’Scores’,’Labels’});
% Run the detector on images in the test set and collect the results.
reset(testData)
while hasdata(testData)
% Read the datastore and get the image.
data = read(testData);
image = data{1,1};
% Run the detector.
executionEnvironment = ‘auto’;
[bboxes,scores,labels] = detectComplexYOLOv4(net,image,anchorBoxes,classNames,executionEnvironment);
% Collect the results.
tbl = table({bboxes},{scores},{labels},’VariableNames’,{‘Boxes’,’Scores’,’Labels’});
results = [results; tbl];
end
% Evaluate the object detector using the average precision metric.
metrics = evaluateDetectionAOS(results, testData)
Got this error
Error using dlarray/crossentropy
Invalid argument name ‘ClassificationMode’. Name must be ‘TargetCategories’, ‘Mask’, ‘Reduction’, ‘NormalizationFactor’, ‘DataFormat’, or ‘WeightsFormat’.
Error in complexYolotrial>@(a,b,c)crossentropy(a.*c,b.*c,’ClassificationMode’,’multilabel’) (line 400)
objLoss = sum(cellfun(@(a,b,c) crossentropy(a.*c,b.*c,’ClassificationMode’,’multilabel’),objectnessPredCell,objectnessDeltaTarget,boxMaskTarget(:,2)));
Error in complexYolotrial>objectnessLoss (line 400)
objLoss = sum(cellfun(@(a,b,c) crossentropy(a.*c,b.*c,’ClassificationMode’,’multilabel’),objectnessPredCell,objectnessDeltaTarget,boxMaskTarget(:,2)));
Error in complexYolotrial>modelGradients (line 339)
objLoss = objectnessLoss(YPredCell(:,1),objectnessTarget,objectMaskTarget);
Error in deep.internal.dlfeval (line 17)
[varargout{1:nargout}] = fun(x{:});
Error in deep.internal.dlfevalWithNestingCheck (line 15)
[varargout{1:nargout}] = deep.internal.dlfeval(fun,varargin{:});
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:}); how to resolve itWhile using this code from Complex yolo document in R2023a version
doTraining = true;
if doTraining
iteration = 0;
% Create subplots for the learning rate and mini-batch loss.
fig = figure;
[lossPlotter, learningRatePlotter] = configureTrainingProgressPlotter(fig);
% Custom training loop.
for epoch = 1:maxEpochs
reset(mbqTrain);
shuffle(mbqTrain);
while(hasdata(mbqTrain))
iteration = iteration + 1;
[XTrain,YTrain] = next(mbqTrain);
% Evaluate the model gradients and loss using dlfeval and the
% modelGradients function.
[gradients,state,lossInfo] = dlfeval(@modelGradients,net,XTrain,YTrain,anchorBoxes,penaltyThreshold,networkOutputs);
% Apply L2 regularization.
gradients = dlupdate(@(g,w) g + l2Regularization*w, gradients, net.Learnables);
% Determine the current learning rate value.
currentLR = piecewiseLearningRateWithWarmup(iteration,epoch,learningRate,warmupPeriod,maxEpochs);
% Update the network learnable parameters using the SGDM optimizer.
[net,velocity] = sgdmupdate(net,gradients,velocity,currentLR);
% Update the state parameters of dlnetwork.
net.State = state;
% Display progress.
if mod(iteration,10)==1
displayLossInfo(epoch,iteration,currentLR,lossInfo);
end
% Update training plot with new points.
updatePlots(lossPlotter,learningRatePlotter,iteration,currentLR,lossInfo.totalLoss);
end
end
else
net = mdl.net;
anchorBoxes = mdl.anchorBoxes;
end
% Create a table to hold the bounding boxes, scores, and labels returned by
% the detector.
results = table(‘Size’,[0 3], …
‘VariableTypes’,{‘cell’,’cell’,’cell’}, …
‘VariableNames’,{‘Boxes’,’Scores’,’Labels’});
% Run the detector on images in the test set and collect the results.
reset(testData)
while hasdata(testData)
% Read the datastore and get the image.
data = read(testData);
image = data{1,1};
% Run the detector.
executionEnvironment = ‘auto’;
[bboxes,scores,labels] = detectComplexYOLOv4(net,image,anchorBoxes,classNames,executionEnvironment);
% Collect the results.
tbl = table({bboxes},{scores},{labels},’VariableNames’,{‘Boxes’,’Scores’,’Labels’});
results = [results; tbl];
end
% Evaluate the object detector using the average precision metric.
metrics = evaluateDetectionAOS(results, testData)
Got this error
Error using dlarray/crossentropy
Invalid argument name ‘ClassificationMode’. Name must be ‘TargetCategories’, ‘Mask’, ‘Reduction’, ‘NormalizationFactor’, ‘DataFormat’, or ‘WeightsFormat’.
Error in complexYolotrial>@(a,b,c)crossentropy(a.*c,b.*c,’ClassificationMode’,’multilabel’) (line 400)
objLoss = sum(cellfun(@(a,b,c) crossentropy(a.*c,b.*c,’ClassificationMode’,’multilabel’),objectnessPredCell,objectnessDeltaTarget,boxMaskTarget(:,2)));
Error in complexYolotrial>objectnessLoss (line 400)
objLoss = sum(cellfun(@(a,b,c) crossentropy(a.*c,b.*c,’ClassificationMode’,’multilabel’),objectnessPredCell,objectnessDeltaTarget,boxMaskTarget(:,2)));
Error in complexYolotrial>modelGradients (line 339)
objLoss = objectnessLoss(YPredCell(:,1),objectnessTarget,objectMaskTarget);
Error in deep.internal.dlfeval (line 17)
[varargout{1:nargout}] = fun(x{:});
Error in deep.internal.dlfevalWithNestingCheck (line 15)
[varargout{1:nargout}] = deep.internal.dlfeval(fun,varargin{:});
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:}); how to resolve it While using this code from Complex yolo document in R2023a version
doTraining = true;
if doTraining
iteration = 0;
% Create subplots for the learning rate and mini-batch loss.
fig = figure;
[lossPlotter, learningRatePlotter] = configureTrainingProgressPlotter(fig);
% Custom training loop.
for epoch = 1:maxEpochs
reset(mbqTrain);
shuffle(mbqTrain);
while(hasdata(mbqTrain))
iteration = iteration + 1;
[XTrain,YTrain] = next(mbqTrain);
% Evaluate the model gradients and loss using dlfeval and the
% modelGradients function.
[gradients,state,lossInfo] = dlfeval(@modelGradients,net,XTrain,YTrain,anchorBoxes,penaltyThreshold,networkOutputs);
% Apply L2 regularization.
gradients = dlupdate(@(g,w) g + l2Regularization*w, gradients, net.Learnables);
% Determine the current learning rate value.
currentLR = piecewiseLearningRateWithWarmup(iteration,epoch,learningRate,warmupPeriod,maxEpochs);
% Update the network learnable parameters using the SGDM optimizer.
[net,velocity] = sgdmupdate(net,gradients,velocity,currentLR);
% Update the state parameters of dlnetwork.
net.State = state;
% Display progress.
if mod(iteration,10)==1
displayLossInfo(epoch,iteration,currentLR,lossInfo);
end
% Update training plot with new points.
updatePlots(lossPlotter,learningRatePlotter,iteration,currentLR,lossInfo.totalLoss);
end
end
else
net = mdl.net;
anchorBoxes = mdl.anchorBoxes;
end
% Create a table to hold the bounding boxes, scores, and labels returned by
% the detector.
results = table(‘Size’,[0 3], …
‘VariableTypes’,{‘cell’,’cell’,’cell’}, …
‘VariableNames’,{‘Boxes’,’Scores’,’Labels’});
% Run the detector on images in the test set and collect the results.
reset(testData)
while hasdata(testData)
% Read the datastore and get the image.
data = read(testData);
image = data{1,1};
% Run the detector.
executionEnvironment = ‘auto’;
[bboxes,scores,labels] = detectComplexYOLOv4(net,image,anchorBoxes,classNames,executionEnvironment);
% Collect the results.
tbl = table({bboxes},{scores},{labels},’VariableNames’,{‘Boxes’,’Scores’,’Labels’});
results = [results; tbl];
end
% Evaluate the object detector using the average precision metric.
metrics = evaluateDetectionAOS(results, testData)
Got this error
Error using dlarray/crossentropy
Invalid argument name ‘ClassificationMode’. Name must be ‘TargetCategories’, ‘Mask’, ‘Reduction’, ‘NormalizationFactor’, ‘DataFormat’, or ‘WeightsFormat’.
Error in complexYolotrial>@(a,b,c)crossentropy(a.*c,b.*c,’ClassificationMode’,’multilabel’) (line 400)
objLoss = sum(cellfun(@(a,b,c) crossentropy(a.*c,b.*c,’ClassificationMode’,’multilabel’),objectnessPredCell,objectnessDeltaTarget,boxMaskTarget(:,2)));
Error in complexYolotrial>objectnessLoss (line 400)
objLoss = sum(cellfun(@(a,b,c) crossentropy(a.*c,b.*c,’ClassificationMode’,’multilabel’),objectnessPredCell,objectnessDeltaTarget,boxMaskTarget(:,2)));
Error in complexYolotrial>modelGradients (line 339)
objLoss = objectnessLoss(YPredCell(:,1),objectnessTarget,objectMaskTarget);
Error in deep.internal.dlfeval (line 17)
[varargout{1:nargout}] = fun(x{:});
Error in deep.internal.dlfevalWithNestingCheck (line 15)
[varargout{1:nargout}] = deep.internal.dlfeval(fun,varargin{:});
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:}); how to resolve it deep learning MATLAB Answers — New Questions