Predict unique label from a pair of output classification vectors

username: manurare
cooked: <p>I have a question regarding how to implement the test phase in the system described on the image</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/9/9/9957dc4fb66b0d1a8d55ad5f8f567e5be31feac1.png" data-download-href="https://discuss.pytorch.org/uploads/default/9957dc4fb66b0d1a8d55ad5f8f567e5be31feac1" title="forum_flowchart"><img src="https://discuss.pytorch.org/uploads/default/original/3X/9/9/9957dc4fb66b0d1a8d55ad5f8f567e5be31feac1.png" alt="forum_flowchart" data-base62-sha1="lSxibVYxO5MGqjY8wFGY9bqsVtT" width="453" height="500" data-dominant-color="F8F8F8"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">forum_flowchart</span><span class="informations">458×505 2.33 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>I have trained both N1 and N2 to transform an input image (Im) wrt to Im’s class. If Im belongs to class 1 (C1) then I updated N1. If it belongs to C2 I update C2. At the same time I update the classifier to reckon the transformation which is inherent to each class.</p>
<p>Now, that the system is trained I want to predict new incoming samples. As I do not have any label that tells me which network (N1 or N2) has to transform Im, then I need to feed it to both and therefore I will have two transformed images T1 and T2. My classifier needs to assign two labels now during test but I need just one. In theory, if the input image belongs to class 2 then T1 is an image that the classifier should classify with low confidence whereas T2 should have a higher confidence and viceversa. My problem is that I dont know how to implement this idea. I have tried too many things. The output of my classifier is a vector of two values for each image. Therefore I will have a pair of vectors (C1_t1,C2_t1) and (C1_t2, C2_t2) indicating the probabilities of each transformed image T1, T2 of belonging to classes C1,C2. I need to find a way from those values to output the final class.</p>

username: ptrblck
cooked: <p>That’s a tricky question, as your training and testing routine are different, i.e. during training your model architecture was changing based on the target.<br>
How did you implement the validation step or did you just train the model?</p>
<p>Once approach would be to use a small hold-out set to train another classifier on top of your current model to use the 4 predictions and output only the two classes.</p>

username: manurare
cooked: <p>I did not implement a validation step because I came up with the same question. I could use the GT label during validation, because if you do that you know which network N1 or N2 the input should be fed through and that’s not how it is supposed to be evaluated. Therefore, I have just trained the model.</p>
<blockquote>
<p>Once approach would be to use a small hold-out set to train another classifier on top of your current model to use the 4 predictions and output only the two classes.</p>
</blockquote>
<p>What do you mean by that? If I trained a classifier in top of both N1 and N2 to predict the label of the input am I leveraging the fact of N1 and N2 transforming the input differently with regard to the class it belongs to? I want to output only one class. So if input belongs to C1 the classifier should be used to see T1-like images and not T2-like as in training never happened a C1 input to be fed into N2. But actually it seems that my classifier did not learn about class features of the image but only about the transformation. I don’t know if my thoughts are correct.</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="manurare" data-post="4" data-topic="75022">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/manurare/48/12026_2.png" class="avatar"> manurare:</div>
<blockquote>
<p>So if input belongs to C1 the classifier should be used to see T1-like images and not T2-like as in training never happened a C1 input to be fed into N2. But actually it seems that my classifier did not learn about class features of the image but only about the transformation. I don’t know if my thoughts are correct.</p>
</blockquote>
</aside>
<p>That’s what I’m concerned about.<br>
You are using the targets to switch between different transformations as well as different model paths, which would not be possible in your validation and test use cases.</p>