Solved by Deepali in post #2 
              
              
                w -= 0.01 * w.grad is an in-place operation, so it performs calculation on existing w and updates the value. 
However,  w = w - 0.01 * w.grad is not in-place operation, so it creates a new variable w, which does not have requires_grad set and so the error. 
You can quickly check this by calling - pr…