Weighting Classes in a Binary Classification Neural Network

조회 수: 1 (최근 30일)
Arjun Desai
Arjun Desai 2018년 5월 25일
댓글: Eugene Alexander 2019년 5월 28일
I am building a binary classification neural network. The last 3 layers of my CNN architecture are the following:
fullyConnectedLayer(2, 'Name', 'fc1');
softmaxLayer
classificationLayer
Currently, the classificationLayer uses a crossentropyex loss function, but this loss function weights the binary classes (0, 1) the same. Unfortunately, in my total data is have substantially less information about the 0 class than about the 1 class.
As a result, I want to weight the loss function to penalize misclassifying the 0 class more, with classWeights proportional to 1/(class frequency).
I noted that there is a way to weight classes in the pixelClassificationLayer but not the general classificationLayer, which I would be using as I am working on a classification problem.
How can I add class weights to my loss function for training?
  댓글 수: 3
Arjun Desai
Arjun Desai 2019년 3월 24일
Hi Samreen,
Unfortunately i could not find a good work around. might be something to pitch for future development.
Arjun
Eugene Alexander
Eugene Alexander 2019년 5월 28일
Please take a look at Define Custom Weighted Classification Layer and the example on Speech Command Recognition using Deep Learning. I am trying it right now on a binary classification problem.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Pattern Recognition and Classification에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by