expand_right¶
- class tensordict.utils.expand_right(tensor: Tensor, shape: Sequence[int])¶
Expand a tensor on the right to match a desired shape.
- Parameters:
tensor – tensor to be expanded
shape – target shape
- Returns:
a tensor with shape matching the target shape.
Examples
>>> tensor = torch.zeros(3,4) >>> shape = (3,4,5) >>> print(expand_right(tensor, shape).shape) torch.Size([3,4,5])