I have seen a lot of examples that for tensor x they use x.grad or for parameter (a subclass of tensor) they use param.data.
Are these two properties of Tensor? If they are why can’t I find, for example grad, in TORCH.TENSOR properties?
I have seen a lot of examples that for tensor x they use x.grad or for parameter (a subclass of tensor) they use param.data.
Are these two properties of Tensor? If they are why can’t I find, for example grad, in TORCH.TENSOR properties?
You can find the docs for torch.tensor.grad
here.
I wouldn’t recommend to use .data
, but instead wrap your code in a torch.no_grad()
block, if you would like to manipulate the data:
with torch.no_grad():
module.weight[0, 0] = 1