Hi Saif!
Probably the most practical next step for you to debug your issue
would be for you to go through your code, systematically trimming
out everything you can, while still preserving the issue.
Whittle it down to a short, self-contained, runnable script that
reproduces your issue.  Not only is this a good approach to debugging;
it lowers the barrier to people on the forum being able to help you
if you have further questions.



 Saif_Ali_Khan:

optimizer = torch.optim.SGD (model.parameters(), lr = 0.01)
...
prediction(model, x, t, 'regression')
print ('a =', a)
print ('b =', b)
for param in model_new.parameters():
    print(param)



We have no way to tell whether this is right or wrong.
You optimize model, but then you call something called prediction()
and print out the parameters() of something called model_new.
Who knows what model_new is or what its parameters() should
be equal to?
Good luck.
K. Frank