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