torch_sub function

Sub

Sub

torch_sub(self, other, alpha = 1L)

Arguments

  • self: (Tensor) the input tensor.
  • other: (Tensor or Scalar) the tensor or scalar to subtract from input
  • alpha: the scalar multiplier for other

sub(input, other, *, alpha=1, out=None) -> Tensor

Subtracts other, scaled by alpha, from input.

\mboxouti=\mboxinputi\mboxalpha×\mboxotheri \mbox{{out}}_i = \mbox{{input}}_i - \mbox{{alpha}} \times \mbox{{other}}_i

Supports broadcasting to a common shape , type promotion , and integer, float, and complex inputs.

Examples

if (torch_is_installed()) { a <- torch_tensor(c(1, 2)) b <- torch_tensor(c(0, 1)) torch_sub(a, b, alpha=2) }
  • Maintainer: Daniel Falbel
  • License: MIT + file LICENSE
  • Last published: 2025-02-14

Downloads (last 30 days):