What is the cause of Training loss lower than validation loss

Rexedoziem: <p>My training loss is lower than my validation loss, I need to know the cause and how to scale it up?</p>

srishti-git1110: <p>How less?<br>
Could you please show some plots/values?</p>

Rexedoziem: <p>train loss —- 4.63e-5  valid loss —- 0.0094<br>
train loss — 0.000427 valid loss —- 0.0020<br>
train loss —- 0.000344 valid loss —- 0.0025</p>

AlphaBetaGamma96: <p>It seems you’re just overfitting your training data.</p>

Rexedoziem: <p>But I added dropout in my model.</p>

AlphaBetaGamma96: <p>Hi <a class="mention" href="/u/rexedoziem">@Rexedoziem</a>,</p>
<p>Can you share some code / more info on what you’re modelling?</p>
<aside class="quote no-group" data-username="Rexedoziem" data-post="5" data-topic="163142" data-full="true">
<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/rexedoziem/48/52029_2.png" class="avatar"> Rexedoziem:</div>
<blockquote>
<p>But I added dropout in my model.</p>
</blockquote>
</aside>
<p>Dropout won’t solve everything, but it can help. You might have too large a model for example, which will have a lower bias (as in relative error to the ground-truth), but has a higher variance (variance in predictions). Vary the size of your network and see if you get similar results.</p>

Rexedoziem: <p>import torch.nn as nn<br>
import torch<br>
from transformers import DebertaModel, DebertaTokenizer<br>
import transformers</p>
<p>class DebertaModel(nn.Module):<br>
def <strong>init</strong>(self):<br>
super(DebertaModel, self).<strong>init</strong>()<br>
self.deberta = BertModel.from_pretrained(‘…/input/bert-base-uncased’, return_dict=False)<br>
self.dropout = nn.Dropout(0.1)<br>
self.classified = nn.Linear(768, config.out_features)</p>
<pre><code>def forward(self, input_ids, attention_mask, token_type_ids):
    _, output = self.deberta(input_ids, attention_mask, token_type_ids)
    output_dropout = self.dropout(output)
    output = self.classified(output_dropout)

    return output
</code></pre>
<p>model = DebertaModel()<br>
model.to(device)</p>

Rexedoziem: <p>from transformers import AdamW, get_linear_schedule_with_warmup<br>
param_optimizer = list(model.named_parameters())<br>
no_decay = [‘bias’, ‘LayerNorm.bias’, ‘LayerNorm.weight’]<br>
optimizer_parameters = [<br>
{‘params’: [p for n, p in param_optimizer if not any(nd in n for nd in no_decay)], ‘weight_decay’ : 0.001},<br>
{‘params’: [p for n, p in param_optimizer if any(nd in n for nd in no_decay)], ‘weight_decay’ : 0.00}<br>
]</p>
<p>num_train_step = int(len(train_df) / config.TRAIN_BATCH_SIZE * config.EPOCHS)<br>
optimizer = torch.optim.AdamW(optimizer_parameters, lr=1e-3)<br>
scheduler = get_linear_schedule_with_warmup(<br>
optimizer,<br>
num_warmup_steps=0,<br>
num_training_steps= num_train_step<br>
)</p>

Rexedoziem: <p>I believe I need to clean the text first before sending it to the model which I can show you.</p>
<p>df[‘full_text’][1]</p>
<p>Out[4]:</p>
<p>“When a problem is a change you have to let it do the best on you no matter what is happening it can change your mind. sometimes you need to wake up and look what is around you because problems are the best way to change what you want to change along time ago. A\n\nproblem is a change for you because it can make you see different and help you to understand how tings wok.\n\nFirst of all it can make you see different then the others. For example i remember that when i came to the United States i think that nothing was going to change me because i think that nothing was going to change me because everything was different that my country and then i realist that wrong because a problem may change you but sometimes can not change the way it is, but i remember that i was really shy but i think that change a lot because sometimes my problems make me think that there is more thing that i never see in my life but i just need to see it from a different way and dont let nothing happened and ruing the change that i want to make because of just a problem. For example i think that nothing was going to change me and that i dont need to be shy anymore became i need to start seeing everything in a different ways because you can get mad at every one but you need to know what is going to happened after,\n\npeople may see you different but the only way that you know how to change is to do the best and don’t let nothing or not body to change nothing about you. The way you want to change not one have that and can’t do nothing about it because is your choice and your problems and you can decide what to do with it.\n\nsecond of all can help you to understand how things work. For instance my mom have a lot of problems but she have faith when she is around people, my mom is scare of high and i’m not scare of high i did not understand why my mos is scare of high and in not scare of high and every time i see my mom in a airplane it make me laugh because she is scare and is funny, but i see it from a different way and i like the high but also she have to understand that hoe things work in other people because it can no be the same as you. For example i think that my mom and me are different because we are and i have to understand that she does not like high and i need to understand that. to help someone to understand how things work you need to start to see how things work in that persons life.\n\nA problem is a change for you and can make you a different and help you to understand. Everyone has a different opinion and a different was to understand then others. everyone can see the different opinion and what other people think.”</p>
<p>So I think I need to clean it first……</p>