Network learn opposite color from desirable

Ella: <p>Hi,</p>
<p>My network learn opposite colour from desirable, I guess it somehow related to weights, but how can I improve this issue? I attached images, black veins  are desirable where white veins are outcome of my network. (my network is UNet)<br>
I trained it for 200 iterations, and I still don’t see desirable change.</p>
<p>Thanks,<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/0/10846d0f90fa4da62e70383750fe7bbaae393369.png" data-download-href="https://discuss.pytorch.org/uploads/default/10846d0f90fa4da62e70383750fe7bbaae393369" title="img2 copy 2"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/0/10846d0f90fa4da62e70383750fe7bbaae393369_2_500x500.png" alt="img2 copy 2" data-base62-sha1="2m7mnxNPmp2FTnFVjlOrKzEf4rD" width="500" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/0/10846d0f90fa4da62e70383750fe7bbaae393369_2_500x500.png, https://discuss.pytorch.org/uploads/default/original/3X/1/0/10846d0f90fa4da62e70383750fe7bbaae393369.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/1/0/10846d0f90fa4da62e70383750fe7bbaae393369.png 2x" data-dominant-color="969696"><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">img2 copy 2</span><span class="informations">560×560 139 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><br>
![img2 copy 2|500x500](upload://2m<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/6/5640c6c77f3050c6fc3c39d974c4ad89ed8bf612.png" data-download-href="https://discuss.pytorch.org/uploads/default/5640c6c77f3050c6fc3c39d974c4ad89ed8bf612" title="img1 copy"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/5/6/5640c6c77f3050c6fc3c39d974c4ad89ed8bf612_2_500x500.png" alt="img1 copy" data-base62-sha1="cj1QpPIOYfxZ9RqFJ9NHcWgqEoO" width="500" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/5/6/5640c6c77f3050c6fc3c39d974c4ad89ed8bf612_2_500x500.png, https://discuss.pytorch.org/uploads/default/original/3X/5/6/5640c6c77f3050c6fc3c39d974c4ad89ed8bf612.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/5/6/5640c6c77f3050c6fc3c39d974c4ad89ed8bf612.png 2x" data-dominant-color="4A4A4A"><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">img1 copy</span><span class="informations">560×560 89.1 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> 7mnxNPmp2FTnFVjlOrKzEf4rD.png)</p>

Manuel_Alejandro_Dia: <p>Could you please provide more information? Maybe post a snippet of code on how do you get these images?</p>
<p>What is the range of values in the output and input? What is the size of the last convolution in your network?</p>
<p>If you are using a <a href="https://arxiv.org/pdf/1505.04597.pdf" rel="noopener nofollow ugc">Unet</a> the output result should be binary and the image you show has many shades. Look at Figure 2, the output of your image should only have black or white.</p>
<p>The main thing I recommend you to look is to use <a href="https://pytorch.org/docs/stable/generated/torch.max.html" rel="noopener nofollow ugc"><code>output.max(1)</code></a> on the output of your network (if you already don’t do this). Here C is the number of the dimension where the channels are in your image. This is usually 1 when working with images: <code>[batch_size, channels, height, width]</code>.</p>
<p>The case may be that the image you are seeing is the logits taken directly from the network output. If your network is training properly, the veins will have the highest pixel values and it might explain why they are white in your image.</p>