For further clarification i dont believe my layers are the real issue as i have run it before without the weighted classes and got no issue it occurs when i try to add class weights to the classification layer and i am unsure why if i am using the function wrong
Using Weighted Classes in CNN
2 views (last 30 days)
Show older comments
Darrien Walters
on 14 Mar 2021
Commented: Darrien Walters
on 21 Mar 2021
In trying to set up my CNN layers with weighted classes I am getting an error that states:
"Error using classificationLayer>iParseInputArguments (line 58)
'ClassWeights' is not a recognized parameter. For a list of valid name-value pair arguments, see the
documentation for this function."
I am unsure if I'm using the class weights incorrectly. The following are the layers of my network:
classes = ["0","1"];
classWeights = 1./countcats(train_output);
classWeights = classWeights'/mean(classWeights);
layers = [
imageInputLayer([480 1 1])
convolution2dLayer([102 1],3,'Stride',1)
batchNormalizationLayer
leakyReluLayer
maxPooling2dLayer(2,'Stride',2,'Padding',[0 0 0 1])
convolution2dLayer([24 1],10,'Stride',1)
batchNormalizationLayer
leakyReluLayer
maxPooling2dLayer(2,'Stride',2,'Padding',[0 0 0 1])
convolution2dLayer([11 1],10,'Stride',1)
batchNormalizationLayer
leakyReluLayer
maxPooling2dLayer(2,'Stride',2,'Padding',[0 0 0 1])
convolution2dLayer([9 1],10,'Stride',1)
batchNormalizationLayer
leakyReluLayer
maxPooling2dLayer(2,'Stride',2,'Padding',[0 0 0 1])
fullyConnectedLayer(30)
fullyConnectedLayer(10)
fullyConnectedLayer(2)
softmaxLayer
classificationLayer('Classes',classes,'ClassWeights',classWeights)];
This error occurs with and without classes present in the brackets.
Accepted Answer
Rishik Ramena
on 21 Mar 2021
The 'ClassWeights' property for the classificationLayer has been introduced in MATLAB R2021a. So if you are running a version prior to this, you are supposed to get this error. Please find the documentation for your installed MATLAB version here.
More Answers (0)
See Also
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!