Haven't understood the concept of remembering computation history and use of .data attribute

These doubts arised for me in lesson 4 of the book.

I do not understand the concept of updating gradients with the help of .data attribute.
Jeremy says that, when we use the .data attribute, it tells Pytorch not to update the gradients using the calculation.
I’m a beginner to coding too, so can anyone please shine light to what he meant by that?

Along with this question,

weights[0] *= 1.0001

seemed to not work. It raised an error:

Leaf variable was used in an inplace operation

So I cloned the parameters to another variable and detached it seeing a similar statement for ‘params’ variable used earlier in the lesson. But I haven’t yet precisely understood why it didn’t work and I seemed to think that this too arised because it’s somewhat similar to my first doubt.

1 Like

Hi Gregory

I assume on are on page 173. If you have a tensor Pytorch will track it so retain the derivative so you do not have to. If you do not want Pytorch to do this a some point you append .data to the variable holding the tensor. Read in the context of the paragraph in the book.

Regards Conwyn

1 Like