Issue in the curve of training

samm: <p>I faced an issue in the curve of accuracy for training and validation as follow<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/a/cacc24171efe3828c29ec1dabee719d95fec2ebb.png" data-download-href="https://discuss.pytorch.org/uploads/default/cacc24171efe3828c29ec1dabee719d95fec2ebb" title="Screenshot from 2024-12-13 18-27-14"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/c/a/cacc24171efe3828c29ec1dabee719d95fec2ebb_2_690x396.png" alt="Screenshot from 2024-12-13 18-27-14" data-base62-sha1="sW1OMszP2VvdoV19m0HmQBQxEiD" width="690" height="396" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/c/a/cacc24171efe3828c29ec1dabee719d95fec2ebb_2_690x396.png, https://discuss.pytorch.org/uploads/default/optimized/3X/c/a/cacc24171efe3828c29ec1dabee719d95fec2ebb_2_1035x594.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/c/a/cacc24171efe3828c29ec1dabee719d95fec2ebb.png 2x" 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">Screenshot from 2024-12-13 18-27-14</span><span class="informations">1085×624 81 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>this happened after finished the training the model for 50 epochs and resume the training later to be 70 which means add additional 20 epochs … Does that normal i mean resuming the training from the last epoch … Does the curve normal ?</p>

ptrblck: <p>Based on your description the jump in validation accuracy happens when you are resuming the training. If so, I would check for data leaks in your script as it seems the validation data might now contain some or all of the training data.</p>

samm: <p>Thanks a lot for replying . How can i check the data leaks. I mean in which part i should check<br>
do you mean that</p>
<pre><code class="lang-auto">     train_ratio=0.8
    train_size = int(len(dataset) * train_ratio)
    val_size = len(dataset) - train_size
    train_dataset, val_dataset = random_split(dataset, [train_size, val_size])

    train_loader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True)
    val_loader = DataLoader(val_dataset, batch_size=batch_size, shuffle=False)
</code></pre>
<p>but i have imbalance in the images but applied augmentation</p>

ptrblck: <p>Yes, the splitting indices would be reasonable to check first. If you are storing the file names, you could also compare them making sure training samples are not used in the validation run.</p>

samm: <p>Thanks . i will check it now but the imbalance in the dataset , should solve by augmentation or there is another way more efficiently .</p>
<p>as i have 5 classes and one of them contains 3 images only for example</p>

ptrblck: <aside class="quote no-group" data-username="samm" data-post="5" data-topic="214245">
<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/samm/48/36169_2.png" class="avatar"> samm:</div>
<blockquote>
<p>as i have 5 classes and one of them contains 3 images only for example</p>
</blockquote>
</aside>
<p>3 images in total is quite a low number of samples. Image augmentation could help, but using augmentation should not cause any data leaks assuming the data splitting is still valid.</p>