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