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
조회 수: 6 (최근 30일)
이전 댓글 표시
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.
채택된 답변
Rishik Ramena
2021년 3월 21일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!