model_1.state_dict() shows incorrect values for weight and bias, but predictions are correct #974
-
Chapter 1: PyTorch workflow. Section 6. Putting all together State dict shows that weight goes toward 1 and bias toward 0, while real values are 0.7 and 0.3. Code: https://www.kaggle.com/code/dinerville/pytorch-in-a-day-chapter-1-workflow/notebook Can't get my head around why weight and bias are incorrect, but predictions are correct |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello, I saw your code and there are some points. with torch.no_grad(): Also, the main problem in this part is: |
Beta Was this translation helpful? Give feedback.
Hello, I saw your code and there are some points.
The number of repetitions for model 1 is set to 2000, but after 550, it's loss is fixed, so there are 1500 repetitions in vain.
Also, the following code is pointless and there is no need for this code.
with torch.no_grad():
plot_predictions(X_train, y_train, X_test, y_test, predictions=y_pred)
you don't need torch.no_grad().
Also, the main problem in this part is:
X = weight * X + bias
It should be y, not X!