Weird output from a CNN

username: etekiller
cooked: <p>I am working on a CNN which transforms black and white images to color images. I encountered a problem though. The network is basically “averaging out” all input images into this blurry mush you can see on the pic below:</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/2X/1/1b7dcef011da21774a3a55f3df18a780b550144c.jpeg" alt="ai" data-base62-sha1="3VcqXz0tyqdvNrK0ONoJfay0qEk" width="310" height="426"></p>
<p>The loss doesn’t decrease any further regardless of my learning rate setting. This is my average loss per epoch of the training set (red line), and the validation set (blue line):</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/c/cf313f0ac87bf278a02a68a5e028c6ac2c4e8bbe.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/cf313f0ac87bf278a02a68a5e028c6ac2c4e8bbe" title="ai2"><img src="https://discuss.pytorch.org/uploads/default/original/2X/c/cf313f0ac87bf278a02a68a5e028c6ac2c4e8bbe.jpeg" alt="ai2" data-base62-sha1="tyUls2C9j5qdWOO2bp4qpF5NiTY" width="690" height="326" data-dominant-color="0D0C0E"><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">ai2</span><span class="informations">731×346 20.4 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 am using around 3800 images in my training set (randomly flipped vertically, horizontally and randomly rotated up to 180 degrees). Here you can see a few input vs expected output images:</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/2X/6/6f5861417988d13bd8696c9044a328b1c44bdce9.jpeg" alt="ai3" data-base62-sha1="fT0lQds1kfMTfA40y6silbII5U5" width="409" height="424"></p>
<p>I am using MSE and Adam as my loss function and optimizer, respectively.</p>
<p>Could you please help me out with this? I am not sure what to tweak anymore <img src="https://discuss.pytorch.org/images/emoji/apple/frowning.png?v=12" title=":frowning:" class="emoji" alt=":frowning:" loading="lazy" width="20" height="20">.</p>

username: Oli
cooked: <p>Hi, a good practice is to first try to overfit on say, 20-50 images without any validation. If this doesn’t work, there is some bug that keeps the network from learning anything.</p>
<p>Try this, and post a link to your code and I’ll have a look <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

username: etekiller
cooked: <p>Thank you so much for your reply! It’s quite funny because I realized the same thing yesterday. With too many images there will be too much of a deviation between colors, so the loss will always be pushed away from convergence. A few, preferably similar images will get the loss close enough to 0 to generalize any image into a certain set of colours. Am I thinking the right way :D?</p>
<p>Anyways, I used a single image instead of 20-50 to test it out and it seems that now my network is recognizing shapes and trying to colour other images with the style of that single image, which made me really happy.</p>
<p>I also got rid of the linear layers for now, I am testing it on Conv layers only with identity blocks (I read up on them yesterday). I am getting promising partial results from just those Conv layers:</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/2X/4/46665be6706d3c4790acb7acfeab9dc225421bf2.jpeg" alt="ai4" data-base62-sha1="a2MJ0UVDqXvAcccMkTAXQ2Uzf8u" width="601" height="476"></p>
<p>The loss is already between 0.003 and 0.009 <img src="https://discuss.pytorch.org/images/emoji/apple/smiley.png?v=12" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"> (this is a short test run just to show current loss range, I usually run it for 100,000 epochs to see the decrease) :</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/2X/5/5ac28b09cbf32225db4f26fed9701d5a193d9267.jpeg" alt="ai5" data-base62-sha1="cWTMiFaVMs2txaGA9yhncBPAs07" width="526" height="345"></p>
<p>I will do any necessary tweaks after I get this puppy closer to 0.</p>
<p>Nevertheless, thank you so much for your offer &lt;3.</p>