TransWikia.com

Can we use Binary Cross Entropy for Multiclass Classification?

Data Science Asked by Aditi Agrahari on August 24, 2020

In this link, the author has implemented a CNN which classifies 15 classes and has used Binary Cross Entropy as the loss function. But since it’s multiclass classification, is it valid to use Binary Cross Entropy? Or should we use Categorical Cross Entropy instead?

3 Answers

Use categorical_crossentropy when it comes for Multiclass classification, Because multiclass have more than one exclusive targets which is restricted by the binary_cross_entrophy.

binary_cross_entrophy is used when the target vector has only two levels of class.

In other cases when target vector has more than two levels categorical_crossentropy can be used for better model convergence.

Answered by Arvinthsamy M on August 24, 2020

It depends on the problem at hand.

Follow this schema:

  • Binary Cross Entropy: When your classifier must learn two classes. Used with one output node, with Sigmoid activation function and labels take values 0,1.

  • Categorical Cross Entropy: When you When your classifier must learn more than two classes. Used with as many output nodes as the number of classes, with Softmax activation function and labels are one-hot encoded.

It follows that Binary CE can be used for multiclass classification in case an observation can belong to multiple classes at the same time. In that case, belonging to one class doesn't inform the model on belonging to a different class and it's like if any node is an independent output.

Answered by Leevo on August 24, 2020

I think you can. each of your classes need to have a sigmoid output which makes each prediction independent of other classes. there you can use binary cross entropy to calculate the overall error/loss.

Answered by Priyank Jain on August 24, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP