Validation loss doen't decrease, then starts to overfit

username: xymn26094786
cooked: <p>I am training a model to predict whether there are abnormalities in CT images, the input is CT image and the output is the probability.  I use resnet18 as my backbone network and perform data preprocessing as <a href="https://pytorch.org/vision/main/models/generated/torchvision.models.resnet18.html" rel="noopener nofollow ugc">https://pytorch.org/vision/main/models/generated/torchvision.models.resnet18.html </a> suggests.<br>
For loss function, I use focal loss with its parameters gamma=2, alpha=0.5 since there are almost 95% negative samples in my training dataset.<br>
At the begining, the validation loss doesn’t decrease and there is a large gap between training loss and validation loss even without dropout or data augmentation.  I am sure I use same loss function during validation. I have tried reduced the number of layers in the decoder part of my model, but it seems to underfit. Does anyone know what’s going on with this situation?<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/0/70baee38f89dfd028d346c6a890e11a3f4f46cb5.png" data-download-href="https://discuss.pytorch.org/uploads/default/70baee38f89dfd028d346c6a890e11a3f4f46cb5" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/0/70baee38f89dfd028d346c6a890e11a3f4f46cb5_2_690x280.png" alt="image" data-base62-sha1="g5fYmmTfJvkz2x7Jh146Elixu3b" width="690" height="280" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/0/70baee38f89dfd028d346c6a890e11a3f4f46cb5_2_690x280.png, https://discuss.pytorch.org/uploads/default/optimized/3X/7/0/70baee38f89dfd028d346c6a890e11a3f4f46cb5_2_1035x420.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/7/0/70baee38f89dfd028d346c6a890e11a3f4f46cb5.png 2x" data-dominant-color="FBFBFC"><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">image</span><span class="informations">1057×430 24.6 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>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/6/1/614f4fabf3ff94eea197695624ec1ae73dec9bce.png" data-download-href="https://discuss.pytorch.org/uploads/default/614f4fabf3ff94eea197695624ec1ae73dec9bce" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/6/1/614f4fabf3ff94eea197695624ec1ae73dec9bce_2_690x272.png" alt="image" data-base62-sha1="dSQeLnScvhr9Mu5EJOQ5YKHxPYi" width="690" height="272" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/6/1/614f4fabf3ff94eea197695624ec1ae73dec9bce_2_690x272.png, https://discuss.pytorch.org/uploads/default/optimized/3X/6/1/614f4fabf3ff94eea197695624ec1ae73dec9bce_2_1035x408.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/6/1/614f4fabf3ff94eea197695624ec1ae73dec9bce.png 2x" data-dominant-color="FAFAFA"><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">image</span><span class="informations">1114×440 31.8 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>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/1/81d27fc8f626504b4a19ade3e337bbeccb83de57.png" data-download-href="https://discuss.pytorch.org/uploads/default/81d27fc8f626504b4a19ade3e337bbeccb83de57" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/8/1/81d27fc8f626504b4a19ade3e337bbeccb83de57_2_690x268.png" alt="image" data-base62-sha1="iwsAkObDW7lRGsq9aCmLW9sx1vV" width="690" height="268" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/8/1/81d27fc8f626504b4a19ade3e337bbeccb83de57_2_690x268.png, https://discuss.pytorch.org/uploads/default/optimized/3X/8/1/81d27fc8f626504b4a19ade3e337bbeccb83de57_2_1035x402.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/8/1/81d27fc8f626504b4a19ade3e337bbeccb83de57.png 2x" data-dominant-color="FAF9F9"><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">image</span><span class="informations">1139×443 39.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></p>