sachinruk:

for i in range(100): w = w - gamma *w.grad b = b - gamma *b.grad mse.backward()


You are calling mse.backward() 100 times. But you are performing the operation only first time. Please place the operation y = wx + b inside the loop.