Data augmentation in Segmentation

username: edshkim98
cooked: <p>Hello everyone,<br>
I am currently doing my project on segmentation.<br>
The problem with my dataset is that my training and validation dataset is actually slightly different to the actual raw dataset or test dataset.</p>
<p>So, I came up with a solution which is that since data augmentation tends to help regularization and prevents overfitting, I have given a random noise and rotation to my training dataset.<br>
Hence, my training dataset is comprised with 1000 original training dataset + 1000 noisy training dataset while keeping the validation dataset unchanged.<br>
However, my current model is around 94% with 0.87IoU in epoch 50 whereas my original model performance was 95% with 0.89IoU in epoch 50.</p>
<p>Can someone explain to me that whether my data augmentation technique has actually worsen my model’s performance and if not, should I wait for longer epochs to see the results?</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="edshkim98" data-post="1" data-topic="99007">
<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/edshkim98/48/29279_2.png" class="avatar"> edshkim98:</div>
<blockquote>
<p>Can someone explain to me that whether my data augmentation technique has actually worsen my model’s performance and if not, should I wait for longer epochs to see the results?</p>
</blockquote>
</aside>
<p>Data augmentation might increase the model performance on the validation dataset, if the data distribution of the test data would be made more similar to the validation distribution.<br>
E.g. if your validation data contains more gaussian noise, adding this preprocessing step to the training might help.</p>

username: edshkim98
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a>, Thank you for your reply!<br>
Unfortunately, my main goal is to test on the raw dataset, so it is not possible to change the distribution<br>
akin to the validation dataset. My validation data also has similar distribution as the training dataset.<br>
Then my question is, should I also add gaussian noise to my validation dataset or do you still recommend adding noise to generate more data in this case?<br>
I know it would be difficult, but I want to maximize my validation data accuracy as well as accuracy on the raw dataset.<br>
Furthermore, would it be better to train with 1000 original training data + 1000 fixed noised data or 1000 noised data that changes the amount of noise in every epoch? e.g. transforms in torch.vision</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="edshkim98" data-post="3" data-topic="99007">
<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/edshkim98/48/29279_2.png" class="avatar"> edshkim98:</div>
<blockquote>
<p>My validation data also has similar distribution as the training dataset.</p>
</blockquote>
</aside>
<p>I think I misunderstood the use case and thought you might have a slight difference between the training and validation datasets, but it seems the difference is between training+validation vs. test?</p>
<p>I don’t think adding data augmentation to the validation set is a good idea, but also the difference of the test dataset is concerning. A common way would be to decrease the test set and use some of it in the training and validation set. However, if your test set is small or if you don’t have the targets, this won’t be easily possible.<br>
In that case unfortunately I don’t know what the best approach would be to generalize to a “new” data domain.</p>

username: edshkim98
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> Thank you for the reply!<br>
Yeah, unfortunately it is not possible to use the test data for training as there is no target value.<br>
So in this case, do you recommend not using data augmentation to give extra noise onto my training dataset and instead should aim to increase the validation dataset accuracy?</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="edshkim98" data-post="5" data-topic="99007">
<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/edshkim98/48/29279_2.png" class="avatar"> edshkim98:</div>
<blockquote>
<p>and instead should aim to increase the validation dataset accuracy?</p>
</blockquote>
</aside>
<p>That’s hard to tell, since your validation dataset is not a good proxy of the test data.<br>
I.e. even if your training and validation performance is great, your model might just fail on the test dataset, since the distribution could be too different.<br>
Note that “looking” into the test set is not a good idea (you should not observe the test predictions during training), as you would leak the test information into the training.</p>
<p>One other approach, which comes to my mind, would be to use a small portion of the test set to train the model in an unsupervised fashion, e.g. to reconstruct the input.<br>
For this you could use a special “branch” for the output layers to make sure the output shape fits the input shape and remove it later during the classification training. This could maybe pretrain some early layers, but you would have to experiment with it.</p>