torch.broadcast_to¶ torch.broadcast_to(input, shape) → Tensor¶ 将 input 广播到 shape 的形状。相当于调用 input.expand(shape) 。详细信息请参阅 expand() 。 参数: input (Tensor) – 输入张量。 形状(列表、元组或 torch.Size )-新的形状。 示例: >>> x = torch.tensor([1, 2, 3]) >>> torch.broadcast_to(x, (3, 3)) tensor([[1, 2, 3], [1, 2, 3], [1, 2, 3]])