Class Tensor

Hierarchy

Constructors

Properties

_device: Device
_dtype: Dtype
_gradCtx: null | GradientContext
_gradFunc: null | GradientFunction
_node: GraphNodeOutputRef
_requiresGrad: boolean = false
_shape: Shape
_strides: Strides
grad: null | Tensor = null

Accessors

  • get [toStringTag](): string
  • Returns string

  • get isContiguous(): boolean
  • Returns boolean

  • get isScalar(): boolean
  • Returns boolean

  • get node(): GraphNodeOutputRef
  • Returns GraphNodeOutputRef

  • get requiresGrad(): boolean
  • Returns boolean

  • set requiresGrad(value): void
  • Parameters

    • value: boolean

    Returns void

Methods

  • Plot of abs and its gradient

    Calculates:

    output = abs(input)
    

    Gradient:

    inputGrad = input == 0 ? 0 : (input > 0 ? outputGrad : -outputGrad)
    

    Returns Tensor

    the output tensor

  • Plot of abs and its gradient

    Calculates:

    output = abs(input)
    

    Gradient:

    inputGrad = input == 0 ? 0 : (input > 0 ? outputGrad : -outputGrad)
    

    Returns Tensor

    the output tensor

  • Alias for abs.

    Plot of abs and its gradient

    Calculates:

    output = abs(input)
    

    Gradient:

    inputGrad = input == 0 ? 0 : (input > 0 ? outputGrad : -outputGrad)
    

    Returns Tensor

    the output tensor

  • Plot of acos and its gradient

    Calculates:

    output = acos(input)
    

    Gradient:

    inputGrad = -outputGrad / sqrt(1 - input * input)
    

    Returns Tensor

    the output tensor

  • Plot of acos and its gradient

    Calculates:

    output = acos(input)
    

    Gradient:

    inputGrad = -outputGrad / sqrt(1 - input * input)
    

    Returns Tensor

    the output tensor

  • Plot of acosh and its gradient

    Calculates:

    output = acosh(input)
    

    Gradient:

    inputGrad = outputGrad / sqrt(input * input - 1)
    

    Returns Tensor

    the output tensor

  • Plot of acosh and its gradient

    Calculates:

    output = acosh(input)
    

    Gradient:

    inputGrad = outputGrad / sqrt(input * input - 1)
    

    Returns Tensor

    the output tensor

  • Calculates:

    output = input + other * alpha
    

    Gradient:

    inputGrad = outputGrad; otherGrad = outputGrad
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    • Optional alpha: number

      the alpha value to multiply other with

    Returns Tensor

    the output tensor

  • Calculates:

    output = input + other * alpha
    

    Gradient:

    inputGrad = outputGrad; otherGrad = outputGrad
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    • Optional alpha: number

      the alpha value to multiply other with

    Returns Tensor

    the output tensor

  • Calculates:

    output = output && input
    

    with an initial value of output = 1.

    Gradient:

    inputGrad = output ? outputGrad : 0.0
    

    Parameters

    • Optional dim: number | number[]
    • Optional keepdim: boolean

    Returns Tensor

    the output tensor

  • Calculates:

    output = output || input
    

    with an initial value of output = 0.

    Gradient:

    inputGrad = output ? outputGrad : 0.0
    

    Parameters

    • Optional dim: number | number[]
    • Optional keepdim: boolean

    Returns Tensor

    the output tensor

  • Alias for acos.

    Plot of acos and its gradient

    Calculates:

    output = acos(input)
    

    Gradient:

    inputGrad = -outputGrad / sqrt(1 - input * input)
    

    Returns Tensor

    the output tensor

  • Alias for acosh.

    Plot of acosh and its gradient

    Calculates:

    output = acosh(input)
    

    Gradient:

    inputGrad = outputGrad / sqrt(input * input - 1)
    

    Returns Tensor

    the output tensor

  • Alias for asin.

    Plot of asin and its gradient

    Calculates:

    output = asin(input)
    

    Gradient:

    inputGrad = outputGrad / sqrt(1 - input * input)
    

    Returns Tensor

    the output tensor

  • Alias for asinh.

    Plot of asinh and its gradient

    Calculates:

    output = asinh(input)
    

    Gradient:

    inputGrad = outputGrad / sqrt(input * input + 1)
    

    Returns Tensor

    the output tensor

  • Alias for atan.

    Plot of atan and its gradient

    Calculates:

    output = atan(input)
    

    Gradient:

    inputGrad = outputGrad / (input * input + 1)
    

    Returns Tensor

    the output tensor

  • Alias for atan2.

    Calculates:

    output = atan2(input, other)
    

    Gradient:

    inputGrad = outputGrad * other / (input * input + other * other); otherGrad = -outputGrad * input / (input * input + other * other)
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Plot of asin and its gradient

    Calculates:

    output = asin(input)
    

    Gradient:

    inputGrad = outputGrad / sqrt(1 - input * input)
    

    Returns Tensor

    the output tensor

  • Plot of asin and its gradient

    Calculates:

    output = asin(input)
    

    Gradient:

    inputGrad = outputGrad / sqrt(1 - input * input)
    

    Returns Tensor

    the output tensor

  • Plot of asinh and its gradient

    Calculates:

    output = asinh(input)
    

    Gradient:

    inputGrad = outputGrad / sqrt(input * input + 1)
    

    Returns Tensor

    the output tensor

  • Plot of asinh and its gradient

    Calculates:

    output = asinh(input)
    

    Gradient:

    inputGrad = outputGrad / sqrt(input * input + 1)
    

    Returns Tensor

    the output tensor

  • Plot of atan and its gradient

    Calculates:

    output = atan(input)
    

    Gradient:

    inputGrad = outputGrad / (input * input + 1)
    

    Returns Tensor

    the output tensor

  • Calculates:

    output = atan2(input, other)
    

    Gradient:

    inputGrad = outputGrad * other / (input * input + other * other); otherGrad = -outputGrad * input / (input * input + other * other)
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = atan2(input, other)
    

    Gradient:

    inputGrad = outputGrad * other / (input * input + other * other); otherGrad = -outputGrad * input / (input * input + other * other)
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Plot of atan and its gradient

    Calculates:

    output = atan(input)
    

    Gradient:

    inputGrad = outputGrad / (input * input + 1)
    

    Returns Tensor

    the output tensor

  • Parameters

    Returns void

  • Plot of ceil and its gradient

    Calculates:

    output = ceil(input)
    

    Gradient:

    inputGrad = 0
    

    Returns Tensor

    the output tensor

  • Plot of ceil and its gradient

    Calculates:

    output = ceil(input)
    

    Gradient:

    inputGrad = 0
    

    Returns Tensor

    the output tensor

  • Calculates:

    output = other >= 0 ? abs(input) : -abs(input)
    

    Gradient:

    var dir = other >= 0 ? (input >= 0 ? 1.0 : -1.0) : (input >= 0 ? -1.0 : 1.0); inputGrad = input == 0.0 ? 0.0 : outputGrad * dir; otherGrad = 0
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = other >= 0 ? abs(input) : -abs(input)
    

    Gradient:

    var dir = other >= 0 ? (input >= 0 ? 1.0 : -1.0) : (input >= 0 ? -1.0 : 1.0); inputGrad = input == 0.0 ? 0.0 : outputGrad * dir; otherGrad = 0
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Plot of cos and its gradient

    Calculates:

    output = cos(input)
    

    Gradient:

    inputGrad = -outputGrad * sin(input)
    

    Returns Tensor

    the output tensor

  • Plot of cos and its gradient

    Calculates:

    output = cos(input)
    

    Gradient:

    inputGrad = -outputGrad * sin(input)
    

    Returns Tensor

    the output tensor

  • Plot of cosh and its gradient

    Calculates:

    output = cosh(input)
    

    Gradient:

    inputGrad = outputGrad * sinh(input)
    

    Returns Tensor

    the output tensor

  • Plot of cosh and its gradient

    Calculates:

    output = cosh(input)
    

    Gradient:

    inputGrad = outputGrad * sinh(input)
    

    Returns Tensor

    the output tensor

  • Calculates:

    output = output + (input != 0)
    

    with an initial value of output = 0.0.

    Parameters

    • Optional dim: number | number[]
    • Optional keepdim: boolean

    Returns Tensor

    the output tensor

  • Plot of deg2rad and its gradient

    Calculates:

    output = input * 0.017453292519943295
    

    Gradient:

    inputGrad = outputGrad * 0.017453292519943295
    

    Returns Tensor

    the output tensor

  • Plot of deg2rad and its gradient

    Calculates:

    output = input * 0.017453292519943295
    

    Gradient:

    inputGrad = outputGrad * 0.017453292519943295
    

    Returns Tensor

    the output tensor

  • Calculates:

    output = input / other
    

    Gradient:

    inputGrad = outputGrad / other; otherGrad = -outputGrad * input / (other * other)
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = input / other
    

    Gradient:

    inputGrad = outputGrad / other; otherGrad = -outputGrad * input / (other * other)
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Alias for div.

    Calculates:

    output = input / other
    

    Gradient:

    inputGrad = outputGrad / other; otherGrad = -outputGrad * input / (other * other)
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Plot of exp and its gradient

    Calculates:

    output = exp(input)
    

    Gradient:

    inputGrad = outputGrad * exp(input)
    

    Returns Tensor

    the output tensor

  • Plot of exp2 and its gradient

    Calculates:

    output = exp2(input)
    

    Gradient:

    inputGrad = outputGrad * exp2(input) * 0.6931471805599453
    

    Returns Tensor

    the output tensor

  • Plot of exp2 and its gradient

    Calculates:

    output = exp2(input)
    

    Gradient:

    inputGrad = outputGrad * exp2(input) * 0.6931471805599453
    

    Returns Tensor

    the output tensor

  • Plot of exp and its gradient

    Calculates:

    output = exp(input)
    

    Gradient:

    inputGrad = outputGrad * exp(input)
    

    Returns Tensor

    the output tensor

  • Plot of expm1 and its gradient

    Calculates:

    output = exp(input) - 1.0
    

    Gradient:

    inputGrad = outputGrad * exp(input)
    

    Returns Tensor

    the output tensor

  • Plot of expm1 and its gradient

    Calculates:

    output = exp(input) - 1.0
    

    Gradient:

    inputGrad = outputGrad * exp(input)
    

    Returns Tensor

    the output tensor

  • Alias for trunc.

    Plot of trunc and its gradient

    Calculates:

    output = trunc(input)
    

    Gradient:

    inputGrad = 0
    

    Returns Tensor

    the output tensor

  • Parameters

    • startDim: number = 0
    • endDim: number = -1

    Returns Tensor

  • Plot of floor and its gradient

    Calculates:

    output = floor(input)
    

    Gradient:

    inputGrad = 0
    

    Returns Tensor

    the output tensor

  • Plot of floor and its gradient

    Calculates:

    output = floor(input)
    

    Gradient:

    inputGrad = 0
    

    Returns Tensor

    the output tensor

  • Plot of frac and its gradient

    Calculates:

    output = input >= 0.0 ? fract(input) : -fract(-input)
    

    Gradient:

    inputGrad = outputGrad
    

    Returns Tensor

    the output tensor

  • Plot of frac and its gradient

    Calculates:

    output = input >= 0.0 ? fract(input) : -fract(-input)
    

    Gradient:

    inputGrad = outputGrad
    

    Returns Tensor

    the output tensor

  • Calculates:

    output = sqrt(input * input + other * other)
    

    Gradient:

    inputGrad = outputGrad * input / sqrt(input * input + other * other); otherGrad = outputGrad * other / sqrt(input * input + other * other)
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = sqrt(input * input + other * other)
    

    Gradient:

    inputGrad = outputGrad * input / sqrt(input * input + other * other); otherGrad = outputGrad * other / sqrt(input * input + other * other)
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = input * pow(2.0, other)
    

    Gradient:

    var out = pow(2.0, other); inputGrad = outputGrad * out; otherGrad = outputGrad * input * out * 0.6931471805599453
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = input * pow(2.0, other)
    

    Gradient:

    var out = pow(2.0, other); inputGrad = outputGrad * out; otherGrad = outputGrad * input * out * 0.6931471805599453
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Plot of log and its gradient

    Calculates:

    output = log(input)
    

    Gradient:

    inputGrad = outputGrad / input
    

    Returns Tensor

    the output tensor

  • Plot of log10 and its gradient

    Calculates:

    output = log(input) * 0.4342944819032518
    

    Gradient:

    inputGrad = outputGrad / (input * 2.302585092994046)
    

    Returns Tensor

    the output tensor

  • Plot of log10 and its gradient

    Calculates:

    output = log(input) * 0.4342944819032518
    

    Gradient:

    inputGrad = outputGrad / (input * 2.302585092994046)
    

    Returns Tensor

    the output tensor

  • Plot of log1p and its gradient

    Calculates:

    output = log(input + 1.0)
    

    Gradient:

    inputGrad = outputGrad / (input + 1.0)
    

    Returns Tensor

    the output tensor

  • Plot of log1p and its gradient

    Calculates:

    output = log(input + 1.0)
    

    Gradient:

    inputGrad = outputGrad / (input + 1.0)
    

    Returns Tensor

    the output tensor

  • Plot of log2 and its gradient

    Calculates:

    output = log2(input)
    

    Gradient:

    inputGrad = outputGrad / (input * 0.6931471805599453)
    

    Returns Tensor

    the output tensor

  • Plot of log2 and its gradient

    Calculates:

    output = log2(input)
    

    Gradient:

    inputGrad = outputGrad / (input * 0.6931471805599453)
    

    Returns Tensor

    the output tensor

  • Plot of log and its gradient

    Calculates:

    output = log(input)
    

    Gradient:

    inputGrad = outputGrad / input
    

    Returns Tensor

    the output tensor

  • Calculates:

    output = log(exp(input) + exp(other))
    

    Gradient:

    var ein = exp(input); var eoth = exp(other); var addeinv = outputGrad/(ein + eoth); inputGrad = addeinv * ein; otherGrad = addeinv * eoth
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = log2(exp2(input) + exp2(other))
    

    Gradient:

    var ein = exp2(input); var eoth = exp2(other); var sum_ein_eoth = ein + eoth; inputGrad = outputGrad * (ein / sum_ein_eoth); otherGrad = outputGrad * (eoth / sum_ein_eoth );
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = log2(exp2(input) + exp2(other))
    

    Gradient:

    var ein = exp2(input); var eoth = exp2(other); var sum_ein_eoth = ein + eoth; inputGrad = outputGrad * (ein / sum_ein_eoth); otherGrad = outputGrad * (eoth / sum_ein_eoth );
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = log(exp(input) + exp(other))
    

    Gradient:

    var ein = exp(input); var eoth = exp(other); var addeinv = outputGrad/(ein + eoth); inputGrad = addeinv * ein; otherGrad = addeinv * eoth
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = output + input
    

    with an initial value of output = 0.0.

    Gradient:

    inputGrad = outputGrad / f32(inputSize)
    

    Parameters

    • Optional dim: number | number[]
    • Optional keepdim: boolean

    Returns Tensor

    the output tensor

  • Calculates:

    output = input * other
    

    Gradient:

    inputGrad = outputGrad * other; otherGrad = outputGrad * input
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = input * other
    

    Gradient:

    inputGrad = outputGrad * other; otherGrad = outputGrad * input
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Alias for mul.

    Calculates:

    output = input * other
    

    Gradient:

    inputGrad = outputGrad * other; otherGrad = outputGrad * input
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Plot of neg and its gradient

    Calculates:

    output = -input
    

    Gradient:

    inputGrad = -outputGrad
    

    Returns Tensor

    the output tensor

  • Plot of neg and its gradient

    Calculates:

    output = -input
    

    Gradient:

    inputGrad = -outputGrad
    

    Returns Tensor

    the output tensor

  • Alias for neg.

    Plot of neg and its gradient

    Calculates:

    output = -input
    

    Gradient:

    inputGrad = -outputGrad
    

    Returns Tensor

    the output tensor

  • Calculates:

    output = output + input * input
    

    with an initial value of output = 0.0.

    Gradient:

    inputGrad = outputGrad * input / output
    

    Parameters

    • Optional dim: number | number[]
    • Optional keepdim: boolean

    Returns Tensor

    the output tensor

  • Plot of positive and its gradient

    Calculates:

    output = input
    

    Gradient:

    inputGrad = outputGrad
    

    Returns Tensor

    the output tensor

  • Plot of positive and its gradient

    Calculates:

    output = input
    

    Gradient:

    inputGrad = outputGrad
    

    Returns Tensor

    the output tensor

  • Calculates:

    output = input >= 0 || fract(other) != 0 ? pow(input, other) :
    pow(-input, other) * ((i32(other) & 1) != 0 ? -1f : 1f)

    Gradient:

    inputGrad = input >= 0 || fract(other) != 0 ? outputGrad * other * pow(input, other - 1.0) :
    outputGrad * other * pow(-input, other - 1) * ((i32(other - 1) & 1) != 0 ? -1f : 1f);
    otherGrad = outputGrad * pow(input, other) * log(input)

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = input >= 0 || fract(other) != 0 ? pow(input, other) :
    pow(-input, other) * ((i32(other) & 1) != 0 ? -1f : 1f)

    Gradient:

    inputGrad = input >= 0 || fract(other) != 0 ? outputGrad * other * pow(input, other - 1.0) :
    outputGrad * other * pow(-input, other - 1) * ((i32(other - 1) & 1) != 0 ? -1f : 1f);
    otherGrad = outputGrad * pow(input, other) * log(input)

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = output * input
    

    with an initial value of output = 1.0.

    Gradient:

    inputGrad = outputGrad * output / input
    

    Parameters

    • Optional dim: number | number[]
    • Optional keepdim: boolean

    Returns Tensor

    the output tensor

  • Plot of rad2deg and its gradient

    Calculates:

    output = input * 57.29577951308232
    

    Gradient:

    inputGrad = outputGrad * 57.29577951308232
    

    Returns Tensor

    the output tensor

  • Plot of rad2deg and its gradient

    Calculates:

    output = input * 57.29577951308232
    

    Gradient:

    inputGrad = outputGrad * 57.29577951308232
    

    Returns Tensor

    the output tensor

  • Plot of reciprocal and its gradient

    Calculates:

    output = 1.0 / input
    

    Gradient:

    inputGrad = -outputGrad / (input * input)
    

    Returns Tensor

    the output tensor

  • Plot of reciprocal and its gradient

    Calculates:

    output = 1.0 / input
    

    Gradient:

    inputGrad = -outputGrad / (input * input)
    

    Returns Tensor

    the output tensor

  • Plot of relu and its gradient

    Calculates:

    output = max(input, 0.0)
    

    Gradient:

    inputGrad = input > 0.0 ? outputGrad : 0.0
    

    Returns Tensor

    the output tensor

  • Plot of relu and its gradient

    Calculates:

    output = max(input, 0.0)
    

    Gradient:

    inputGrad = input > 0.0 ? outputGrad : 0.0
    

    Returns Tensor

    the output tensor

  • Plot of round and its gradient

    Calculates:

    output = round(input)
    

    Gradient:

    inputGrad = 0
    

    Returns Tensor

    the output tensor

  • Plot of round and its gradient

    Calculates:

    output = round(input)
    

    Gradient:

    inputGrad = 0
    

    Returns Tensor

    the output tensor

  • Plot of rsqrt and its gradient

    Calculates:

    output = 1.0 / sqrt(input)
    

    Gradient:

    inputGrad = -outputGrad / (2.0 * sqrt(input) * input)
    

    Returns Tensor

    the output tensor

  • Plot of rsqrt and its gradient

    Calculates:

    output = 1.0 / sqrt(input)
    

    Gradient:

    inputGrad = -outputGrad / (2.0 * sqrt(input) * input)
    

    Returns Tensor

    the output tensor

  • Plot of sigmoid and its gradient

    Calculates:

    output = 1.0 / (1.0 + exp(-input))
    

    Gradient:

    var out = 1.0 / (1.0 + exp(-input)); inputGrad = outputGrad * out * (1.0 - out)
    

    Returns Tensor

    the output tensor

  • Plot of sigmoid and its gradient

    Calculates:

    output = 1.0 / (1.0 + exp(-input))
    

    Gradient:

    var out = 1.0 / (1.0 + exp(-input)); inputGrad = outputGrad * out * (1.0 - out)
    

    Returns Tensor

    the output tensor

  • Plot of sign and its gradient

    Calculates:

    output = sign(input)
    

    Gradient:

    inputGrad = 0
    

    Returns Tensor

    the output tensor

  • Plot of sign and its gradient

    Calculates:

    output = sign(input)
    

    Gradient:

    inputGrad = 0
    

    Returns Tensor

    the output tensor

  • Plot of silu and its gradient

    Calculates:

    output = input / (1.0 + exp(-input))
    

    Gradient:

    var out = 1.0 / (1.0 + exp(-input)); inputGrad = outputGrad * (out + input * out * (1.0 - out))
    

    Returns Tensor

    the output tensor

  • Plot of silu and its gradient

    Calculates:

    output = input / (1.0 + exp(-input))
    

    Gradient:

    var out = 1.0 / (1.0 + exp(-input)); inputGrad = outputGrad * (out + input * out * (1.0 - out))
    

    Returns Tensor

    the output tensor

  • Plot of sin and its gradient

    Calculates:

    output = sin(input)
    

    Gradient:

    inputGrad = outputGrad * cos(input)
    

    Returns Tensor

    the output tensor

  • Plot of sin and its gradient

    Calculates:

    output = sin(input)
    

    Gradient:

    inputGrad = outputGrad * cos(input)
    

    Returns Tensor

    the output tensor

  • Plot of sinc and its gradient

    Calculates:

    var inpi = input * 3.141592653589793; output = input == 0.0 ? 1.0 : sin(inpi) / inpi
    

    Gradient:

    var inpi = input * 3.141592653589793; inputGrad = input == 0.0 ? 0.0 : (outputGrad * 3.141592653589793 * (inpi*cos(inpi) - sin(inpi)) / (inpi*inpi))
    

    Returns Tensor

    the output tensor

  • Plot of sinc and its gradient

    Calculates:

    var inpi = input * 3.141592653589793; output = input == 0.0 ? 1.0 : sin(inpi) / inpi
    

    Gradient:

    var inpi = input * 3.141592653589793; inputGrad = input == 0.0 ? 0.0 : (outputGrad * 3.141592653589793 * (inpi*cos(inpi) - sin(inpi)) / (inpi*inpi))
    

    Returns Tensor

    the output tensor

  • Plot of sinh and its gradient

    Calculates:

    output = sinh(input)
    

    Gradient:

    inputGrad = outputGrad * cosh(input)
    

    Returns Tensor

    the output tensor

  • Plot of sinh and its gradient

    Calculates:

    output = sinh(input)
    

    Gradient:

    inputGrad = outputGrad * cosh(input)
    

    Returns Tensor

    the output tensor

  • Plot of sqrt and its gradient

    Calculates:

    output = sqrt(input)
    

    Gradient:

    inputGrad = outputGrad / (2.0 * sqrt(input))
    

    Returns Tensor

    the output tensor

  • Plot of sqrt and its gradient

    Calculates:

    output = sqrt(input)
    

    Gradient:

    inputGrad = outputGrad / (2.0 * sqrt(input))
    

    Returns Tensor

    the output tensor

  • Plot of square and its gradient

    Calculates:

    output = input * input
    

    Gradient:

    inputGrad = outputGrad * 2.0 * input
    

    Returns Tensor

    the output tensor

  • Plot of square and its gradient

    Calculates:

    output = input * input
    

    Gradient:

    inputGrad = outputGrad * 2.0 * input
    

    Returns Tensor

    the output tensor

  • Calculates:

    output = input - other * alpha
    

    Gradient:

    inputGrad = outputGrad; otherGrad = -outputGrad
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    • Optional alpha: number

      the alpha value to multiply other with

    Returns Tensor

    the output tensor

  • Calculates:

    output = input - other * alpha
    

    Gradient:

    inputGrad = outputGrad; otherGrad = -outputGrad
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    • Optional alpha: number

      the alpha value to multiply other with

    Returns Tensor

    the output tensor

  • Alias for sub.

    Calculates:

    output = input - other * alpha
    

    Gradient:

    inputGrad = outputGrad; otherGrad = -outputGrad
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    • Optional alpha: number

      the alpha value to multiply other with

    Returns Tensor

    the output tensor

  • Calculates:

    output = output + input
    

    with an initial value of output = 0.0.

    Gradient:

    inputGrad = outputGrad
    

    Parameters

    • Optional dim: number | number[]
    • Optional keepdim: boolean

    Returns Tensor

    the output tensor

  • Plot of tan and its gradient

    Calculates:

    output = tan(input)
    

    Gradient:

    inputGrad = outputGrad / (cos(input) * cos(input))
    

    Returns Tensor

    the output tensor

  • Plot of tan and its gradient

    Calculates:

    output = tan(input)
    

    Gradient:

    inputGrad = outputGrad / (cos(input) * cos(input))
    

    Returns Tensor

    the output tensor

  • Plot of tanh and its gradient

    Calculates:

    output = tanh(input)
    

    Gradient:

    inputGrad = outputGrad * (1.0 - tanh(input) * tanh(input))
    

    Returns Tensor

    the output tensor

  • Plot of tanh and its gradient

    Calculates:

    output = tanh(input)
    

    Gradient:

    inputGrad = outputGrad * (1.0 - tanh(input) * tanh(input))
    

    Returns Tensor

    the output tensor

  • Plot of trunc and its gradient

    Calculates:

    output = trunc(input)
    

    Gradient:

    inputGrad = 0
    

    Returns Tensor

    the output tensor

  • Plot of trunc and its gradient

    Calculates:

    output = trunc(input)
    

    Gradient:

    inputGrad = 0
    

    Returns Tensor

    the output tensor

  • Parameters

    • lowerBound: number
    • upperBound: number

    Returns Tensor

  • Calculates:

    output = input == 0.0 ? 0.0 : input * log(other)
    

    Gradient:

    inputGrad = input == 0.0 ? 0.0 : outputGrad * log(other); otherGrad = input == 0.0 ? 0.0 : outputGrad * (input / other);
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

  • Calculates:

    output = input == 0.0 ? 0.0 : input * log(other)
    

    Gradient:

    inputGrad = input == 0.0 ? 0.0 : outputGrad * log(other); otherGrad = input == 0.0 ? 0.0 : outputGrad * (input / other);
    

    Parameters

    • other: number | Tensor

      the other tensor whose shape is broadcastable with the input tensor

    Returns Tensor

    the output tensor

Generated using TypeDoc