expand_as_right¶
- class tensordict.utils.expand_as_right(tensor: torch.Tensor | TensorDictBase, dest: torch.Tensor | TensorDictBase)¶
Expand a tensor on the right to match another tensor shape.
- Parameters:
tensor – tensor to be expanded
dest – tensor providing the target shape
- Returns:
a tensor with shape matching the dest input tensor shape.
Examples
>>> tensor = torch.zeros(3,4) >>> dest = torch.zeros(3,4,5) >>> print(expand_as_right(tensor, dest).shape) torch.Size([3,4,5])