快捷方式

expand_right

class tensordict.utils.expand_right(tensor: Tensor, shape: Sequence[int])

在右侧扩展张量以匹配期望的形状。

参数:
  • tensor – 要扩展的张量

  • shape – 目标形状

返回:

具有与目标形状匹配的形状的张量。

示例

>>> tensor = torch.zeros(3,4)
>>> shape = (3,4,5)
>>> print(expand_right(tensor, shape).shape)
torch.Size([3,4,5])

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得解答

查看资源