Value of train loss is very large

ran_ran1: <p>Hi,<br>
When I call the train method for a previously executed code I get different and large values of train_loss and val_score compared to the expected output<br>
I  only modified  num_workers=0 instead of num_workers=2 and  in loss_function I put reduction=‘sum’ /‘mean’ instead of  size_average=false  and train_loss += loss.item() instead of train_loss += loss.data[0]<br>
this is what I got:<br>
====&gt; Epoch 1 | Train time: 22280.0055 ms| End time: 30543.6549 ms | Train loss: 124908514341585682432.0000 | Val loss: 157350129654111232.0000<br>
====&gt; Epoch 2 | Train time: 32893.7201 ms| End time: 41595.8421 ms | Train loss: 124899982131354140672.0000 | Val loss: 157340963977348576.0000<br>
====&gt; Epoch 3 | Train time: 5325.6693 ms| End time: 9422.5409 ms | Train loss: 124891590658610954240.0000 | Val loss: 157332308998118176.0000<br>
====&gt; Epoch 4 | Train time: 4294.8182 ms| End time: 11010.9062 ms | Train loss: 124882917710891057152.0000 | Val loss: 157323412109530400.0000<br>
====&gt; Epoch 5 | Train time: 3687.0134 ms| End time: 9978.2672 ms | Train loss: 124873804958520049664.0000 | Val loss: 157314125478089088.0000<br>
====&gt; Epoch 6 | Train time: 3680.8324 ms| End time: 10421.0193 ms | Train loss: 124863944538242154496.0000 | Val loss: 157304785089012768.0000<br>
====&gt; Epoch 7 | Train time: 3582.6883 ms| End time: 10224.6709 ms | Train loss: 124853644313313148928.0000 | Val loss: 157295431260527744.0000<br>
…<br>
and this is what I should get:<br>
===&gt; Epoch 1 | Train time: 1698.5452 ms| End time: 3036.2639 ms | Train loss: 29.3311 | Val loss: 18.4107<br>
====&gt; Epoch 2 | Train time: 1537.3888 ms| End time: 2866.3790 ms | Train loss: 23.3025 | Val loss: 18.3386<br>
====&gt; Epoch 3 | Train time: 1542.4740 ms| End time: 2884.9881 ms | Train loss: 23.2476 | Val loss: 16.7314<br>
====&gt; Epoch 4 | Train time: 1525.3885 ms| End time: 2869.0510 ms | Train loss: 22.8955 | Val loss: 17.5893<br>
====&gt; Epoch 5 | Train time: 1539.6032 ms| End time: 2873.3907 ms | Train loss: 21.6304 | Val loss: 16.0720<br>
====&gt; Epoch 6 | Train time: 1496.8140 ms| End time: 2832.1874 ms | Train loss: 21.3513 | Val loss: 16.0074<br>
====&gt; Epoch 7 | Train time: 1514.0126 ms| End time: 2854.8751 ms | Train loss: 20.4407 | Val loss: 15.8153</p>
<p>this is the code<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/d/1dcdbe2435ec673e911e1c8ba0f7b412a31de86a.png" data-download-href="https://discuss.pytorch.org/uploads/default/1dcdbe2435ec673e911e1c8ba0f7b412a31de86a" title="dd"><img src="https://discuss.pytorch.org/uploads/default/original/3X/1/d/1dcdbe2435ec673e911e1c8ba0f7b412a31de86a.png" alt="dd" data-base62-sha1="4fEEcza9io3aKIrihs2WvX8G33k" width="627" height="500" data-dominant-color="F9F9F9"><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">dd</span><span class="informations">1198×955 44.9 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>can I get help</p>