Answers.Body: <p>You can create a mapping from classes to colors for a simple one is:</p>
  <pre><code>y # y.shape = (W, H, n_classes)
  _, y_color = y.max(dim=-1, keepdim=True) / n_classes # y_color.shape = (W, H, 1)
  y_color = torch.cat([y_color] * 3, dim=-1) # y_color.shape = (W, H, 3)
  
  </code></pre>
  <p>(using pytorch like code)</p>
  <p>This mapping is visualizable, of course, you may get nicer visualizations if your class to color mapping is more sophisticated.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-20T12:56:56.860Z
Answers.LastActivityDate: 2020-07-20T12:56:56.860Z
Answers.UserDisplayName: Victor Zuanazzi
Body: <p>When we are doing multi-label segmentation tasks, our <code>y_true</code> (the mask) will be <code>(w, h, 3)</code>, but, in our model, at the last layer, we will be getting <code>(w, h, number of classes)</code> as output.</p>
  <p>How do we make our outputs to have the same size as the true mask so that to apply the loss function, given that, currently, the shapes are not equal? Also, if we are done with applying the loss function and trained the model, how do I make results in the shape of <code>(w, h, 3)</code> from <code>(w, h, number of classes)</code>?</p>
  
Tags: <deep-learning><image-segmentation>
Title: How do we make our outputs to have the same size as the true mask?
UserDisplayName: Ravi Teja
ThreadText: # How do we make our outputs to have the same size as the true mask?
  
  (Asked by: username_0 on 2020-07-20)
  
  When we are doing multi-label segmentation tasks, our `y_true` (the mask) will be `(w, h, 3)`, but, in our model, at the last layer, we will be getting `(w, h, number of classes)` as output.
  
  How do we make our outputs to have the same size as the true mask so that to apply the loss function, given that, currently, the shapes are not equal? Also, if we are done with applying the loss function and trained the model, how do I make results in the shape of `(w, h, 3)` from `(w, h, number of classes)`?
  
  **Tags:** deep-learning, image-segmentation
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-07-20. Score: 0
  
  You can create a mapping from classes to colors for a simple one is:
  
  ```
  y # y.shape = (W, H, n_classes)
  _, y_color = y.max(dim=-1, keepdim=True) / n_classes # y_color.shape = (W, H, 1)
  y_color = torch.cat([y_color] * 3, dim=-1) # y_color.shape = (W, H, 3)
  
  ```
  
  (using pytorch like code)
  
  This mapping is visualizable, of course, you may get nicer visualizations if your class to color mapping is more sophisticated.
  
  
  ---
  
  