torch.broadcast_to¶ torch.broadcast_to(input, shape) → 张量¶ 将 input 广播到形状 shape。 等同于调用 input.expand(shape)。详情请参见 expand()。 Parameters 输入 (张量) – 输入张量。 形状(列表、元组或torch.Size)– 新的形状。 示例: >>> x = torch.tensor([1, 2, 3]) >>> torch.broadcast_to(x, (3, 3)) tensor([[1, 2, 3], [1, 2, 3], [1, 2, 3]])