Multilabel Image Classification Using Deep Learning--Imbalanced Data
10 views (last 30 days)
Show older comments
When I use imbalanced multilabel data to study the example ''openExample('nnet/MultilabelImageClassificationUsingDeepLearningExample') '' ,I found that the loss funtion(CustomBinaryCrossEntropyLossLayer.m, crossentropy) could not be weightd. So I want to use classificationlayer to replace, but classificationlayer could not used in multilabel data.
The crossentropy fuction in supporting file doesn't have Multi-label classificaion with weighted classes.The label is onehotlabel and we use sigmoid instead of softmax.So ,how can I create the outputlayer to achieve Multi-label classificaion with weighted classes?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1112490/image.png)
3 Comments
Tarily
on 13 Jun 2023
Did you solve this problem? I have the same issue now and I hope to get your help.ðŸ˜
Accepted Answer
Varun Sai Alaparthi
on 12 Jan 2023
Hello XT,
There is no direct example or functionality as of MATLAB R2022b to directly do weighted multilabel classification.
But as a workaround you can try building the custom weighted cross entropy layer. Please refer the following link to get more information on this
Or you can try building custom classification layer with Tversky loss which is especially built to handle unbalanced data . You can check the following link for more information on this
Alternatively, there are some ways which can be used to balance the dataset before fitting to the classifier to get the better result. These methods are as follows:
- Under Sampling- Removing the unwanted or repeated data from the majority class and keep only a part of these useful points. In this way, there can be some balance in the data.
- Over Sampling- Try to get more data points for the minority class. Or try to replicate some of the data points of the minority class in order to increase cardinality.
- Generate Data- You can decide to generate synthetic data for the minority class for balancing the data. This can be done using SMOTE method. Below is the link to use SMOTE method-https://www.mathworks.com/matlabcentral/fileexchange/38830-smote-synthetic-minority-over-sampling-technique
Refer to this link for more information on oversampling:
I hope this information helps and please reach out for any further issues.
Sincerely
Varun
0 Comments
More Answers (0)
See Also
Categories
Find more on Image Data Workflows 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!