Hi,
Thank you for these tutorials.
I recently went through a course on DL with Keras so I thought it would be a good idea to reproduce what I learned in that course and port it over and learn PyTorch.
It seems that I have got some fundamentals wrong in PyTorch. I copied your code for the linear regression sample, but it doesn’t correctly fit like it did in Keras. Obxviously I am missing something.  Tried different optimizers and learning rates.
PyTorch code

  
      gist.github.com
  
  
    https://gist.github.com/NinZine/0db6b8af0cb020160d8a4264da1b5b8b 69
linear_regression.py
import torch
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import torch.nn as nn
from torch.autograd import Variable
%matplotlib inline

# From here: https://github.com/Dataweekends/zero_to_deep_learning_udemy/blob/master/data/weight-height.csv
df = pd.read_csv('weight-height.csv')
This file has been truncated. show original




  
  
    
    
  
  


Keras code

  
      github.com
  
  
    Dataweekends/zero_to_deep_learning_udemy/blob/master/course/3 Machine Learning.ipynb 10
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Linear Regression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd\n",


  This file has been truncated. show original

  
  
    
    
  
  


What am I doing wrong?
Edit:
Ok, I’ve realised my mistake. Number of epochs could be in the thousands, for example.