Shortcuts

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])

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources