Using Weighted Classes in CNN

2 visualizaciones (últimos 30 días)
Darrien Walters
Darrien Walters el 14 de Mzo. de 2021
Comentada: Darrien Walters el 21 de Mzo. de 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.
  1 comentario
Darrien Walters
Darrien Walters el 14 de Mzo. de 2021
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

Iniciar sesión para comentar.

Respuesta aceptada

Rishik Ramena
Rishik Ramena el 21 de Mzo. de 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.
  1 comentario
Darrien Walters
Darrien Walters el 21 de Mzo. de 2021
Yes I wasnt aware of this at the time thank you for the response

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Deep Learning Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by