Answers.Body: <p>You want to treat the problem as binary classification, and of course use binary cross-entropy.</p>
  <p>The only requirement is to ensure to use a sigmoid activation in your model's last layer.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-27T15:36:53.617Z
Answers.LastActivityDate: 2022-09-27T15:36:53.617Z
Answers.UserDisplayName: Edoardo Guerriero
Body: <p>Say my target with classes <code>A, B, C, D, E</code> is <code>[0, 1, 1, 0, 0]</code>.</p>
  <p>And my output layer is of B x N where N is the number of classes.</p>
  <p>How do I use Categorical Cross Entropy for this?</p>
  
Tags: <pytorch><loss>
Title: How to use Categorical Cross Entropy for Multi-Label Classification?
UserDisplayName: bluewander
ThreadText: # How to use Categorical Cross Entropy for Multi-Label Classification?
  
  (Asked by: username_0 on 2022-09-27)
  
  Say my target with classes `A, B, C, D, E` is `[0, 1, 1, 0, 0]`.
  
  And my output layer is of B x N where N is the number of classes.
  
  How do I use Categorical Cross Entropy for this?
  
  **Tags:** pytorch, loss
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-09-27. Score: 1
  
  You want to treat the problem as binary classification, and of course use binary cross-entropy.
  
  The only requirement is to ensure to use a sigmoid activation in your model's last layer.
  
  
  ---
  
  