TensorDictBase.data#
- property TensorDictBase.data: Any#
the same storage, without autograd.
The leaves of the result share storage with the leaves of the tensordict, and do not require gradients. An in-place change to the result changes the tensordict.
Assigning
td.data = otherrebinds the.dataof each leaf of the tensordict to the matching leaf ofother, astorch.Tensor.datadoes. The leaves then share storage withother: memory-mapped or shared-memory leaves stop writing to their file or shared memory.otherand each of its nested tensordicts must have the batch size of the matching tensordict, and each key ofothermust be in the tensordict.Examples
>>> import torch >>> from tensordict import TensorDict >>> td = TensorDict(x=torch.zeros(3, requires_grad=True), batch_size=[3]) >>> data = td.data >>> data["x"].requires_grad, data["x"].data_ptr() == td["x"].data_ptr() (False, True)
- Type:
A tensordict of the
.dataof every leaf
Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.