torch.sub¶ torch.sub(input, other, *, alpha=1, out=None) → 张量¶ 从 input 中减去按 alpha 缩放的 other。 outi=inputi−alpha×otheri\text{{out}}_i = \text{{input}}_i - \text{{alpha}} \times \text{{other}}_i outi=inputi−alpha×otheri支持广播到通用形状、 类型提升,以及整数、浮点和复数输入。 Parameters 输入 (张量) – 输入张量。 其他 (Tensor 或 数字) – 要从 input 中减去的张量或数字。 Keyword Arguments alpha (数字) – other 的乘数。 输出 (张量, 可选) – 输出张量。 示例: >>> a = torch.tensor((1, 2)) >>> b = torch.tensor((0, 1)) >>> torch.sub(a, b, alpha=2) tensor([1, 0])