expand_right¶ 类 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])