Simple encoder decoder model is overfitting

Rohan_Kumar: <p>I have this simple gru based encoder decoder model pretty, its the same model as<br>
<a href="https://github.com/bentrevett/pytorch-seq2seq/blob/master/2%20-%20Learning%20Phrase%20Representations%20using%20RNN%20Encoder-Decoder%20for%20Statistical%20Machine%20Translation.ipynb" rel="noopener nofollow ugc">seq2seq implementation</a> and yet it is over fitting only after 10 epochs.</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/3X/8/6/86aea1d4c08464185390bd02a7810f6bbdcf38aa.png" alt="image" data-base62-sha1="jds7YJbeT71wqao3mqSaf7eG5h8" width="617" height="467"></p>
<p>the translation is english to spanish, without pretrained embeddings for either.</p>
<p>I have also used this model for a different dataset, where both src and trg are english, and i was trying to develop some relation between those, and that overfits after 1 epoch.</p>
<p>I dont know what is the problem, This is bugging me for the past 1 week, any help would highly appreciated.</p>
<pre><code class="lang-auto">OUTPUT_DIM = eng_vocab_size
INPUT_DIM = esp_vocab_size
ENC_EMB_DIM = 256
DEC_EMB_DIM = 256
HID_DIM = 512
ENC_DROPOUT = 0.5
DEC_DROPOUT = 0.5
enc = Encoder(INPUT_DIM, HID_DIM, ENC_EMB_DIM, ENC_DROPOUT)
dec = Decoder(DEC_EMB_DIM, HID_DIM, OUTPUT_DIM, DEC_DROPOUT)

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

model = Seq2Seq(enc, dec, device).to(device)
</code></pre>
<p>this is the model initialization.</p>

ptrblck: <p>To counter overfitting, try to add more regularization (dropout, weight decay), decrease the model capacity (smaller or less layers), add augmentation, and make sure the splits are valid (i.e. the data is equally “hard” in both datasets).</p>

vdw: <p>Apart from <a class="mention" href="/u/ptrblck">@ptrblck</a>’s comment, how large is your dataset? For example, if you use a rather small dataset (maybe just a sample for testing the network), then the distribution of the training and test data could be very different. This would yield in the trends of the losses you observe.</p>

Rohan_Kumar: <p>My dataset contains 8000 data points, and the distribution of val set and train set are similar. I also tried with weight decay, but what is happening is the curve doesn’t look over fitting, but something weird is happening. the min loss achieved during overfitting case is almost the same as non overfitting case, and hence i am still getting poor results.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/3/13aceab82db2a7510fa1a811ac058c6f88597459.png" data-download-href="https://discuss.pytorch.org/uploads/default/13aceab82db2a7510fa1a811ac058c6f88597459" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/3/13aceab82db2a7510fa1a811ac058c6f88597459_2_690x361.png" alt="image" data-base62-sha1="2O3xLyzL4cf4cNBBPpghLqEhTLz" width="690" height="361" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/3/13aceab82db2a7510fa1a811ac058c6f88597459_2_690x361.png, https://discuss.pytorch.org/uploads/default/optimized/3X/1/3/13aceab82db2a7510fa1a811ac058c6f88597459_2_1035x541.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/1/3/13aceab82db2a7510fa1a811ac058c6f88597459.png 2x" data-dominant-color="F8F9FA"><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">1201×630 43.5 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>