Regression accuracy for house price prediction is too high and not improving

username: techboy
cooked: <p>Could somebody help me. I am new to Pytorch and am trying to predict house prices.<br>
I have been able to batch my dataset and do a train-test-split. Even though I trained my model for many epochs my accuracy isn’t really improving or that good.</p>
<p>I used get an error of 1e10 (using MSE). Is this the best it can get or am I doing something wrong.</p>
<p>My training loop:</p>
<pre><code class="lang-auto">epochs=10
final_losses=[]
lrs=2
dif=3
for j in range(lrs):
  ###Backward Propogation-- Define the loss_function,define the optimizer
  loss_function=nn.MSELoss()
  optimizer=torch.optim.Adam(model.parameters(),lr=10**(-j-dif))
  print("\n\n","-"*12)
  print("Lr: ", str(10**(-j-dif)))
  print("-"*12)
  print("\n")
  for i in range(epochs):
    for step,(x, y) in enumerate(train):#tqdm
      y_pred=model(x)
      y_pred=y_pred
      loss=loss_function(y_pred,y)
      final_losses.append(loss)
      optimizer.zero_grad()
      loss.backward()
      optimizer.step()

    print("\nEpoch number: {} and the loss : {}".format(i+1,loss.item()))

</code></pre>
<p>Testing loop:</p>
<pre><code class="lang-auto">#### Prediction In X_test data
d=train
predictions=[]
for x,y in test:
  #print(x)!
  with torch.no_grad():
    for step,i in enumerate(range(len(x))):
      print("Count: {}".format(step+1))
      mse=abs(model(x[i]).tolist()[0]-y[i].tolist())**2
      print("Expected:",y[i].tolist()," Predicted: ",model(x[i]).tolist()[0]," Error: {:.2e}".format(mse))   
  break
</code></pre>
<p>My error plot:<br>
<img src="https://discuss.pytorch.org/uploads/default/original/3X/d/c/dcf84bc0a44f7d9180ba472b6675195fcdfcc525.png" alt="image" data-base62-sha1="vwN0VLLRNoUQMAyjeRsjoRFLXSJ" width="386" height="273"></p>
<p>My predictions:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/4/c4bf5f5750a9cffcbe6927f7d145fc01f45a5f2a.png" data-download-href="https://discuss.pytorch.org/uploads/default/c4bf5f5750a9cffcbe6927f7d145fc01f45a5f2a" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/c/4/c4bf5f5750a9cffcbe6927f7d145fc01f45a5f2a_2_479x500.png" alt="image" data-base62-sha1="s4vB3I9N1hKBTuvxApa7ta2obxw" width="479" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/c/4/c4bf5f5750a9cffcbe6927f7d145fc01f45a5f2a_2_479x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/c/4/c4bf5f5750a9cffcbe6927f7d145fc01f45a5f2a_2_718x750.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/c/4/c4bf5f5750a9cffcbe6927f7d145fc01f45a5f2a_2_958x1000.png 2x" data-dominant-color="434343"><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">1271×1325 93.8 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>I am confused why my expected vs predicted values differ so much.<br>
My complete Notebook: <a href="https://colab.research.google.com/drive/1Vd9fJs0bfd7IZ8D5dHS859EThz1DEB58?usp=sharing" class="inline-onebox" rel="noopener nofollow ugc">Google Colab</a><br>
Any help would be highly appreciated.</p>

username: Hassan_Imani
cooked: <p>I have a problem similar to your problem.<br>
My code is working in keras but not in pytorch.<br>
Please somebody help!</p>