• Pads a tf.Tensor with a given value and paddings.

    This operation implements CONSTANT mode. For REFLECT and SYMMETRIC, refer to tf.mirrorPad.

    Also available are stricter rank-specific methods with the same signature as this method that assert that paddings is of given length.

    • tf.pad1d
    • tf.pad2d
    • tf.pad3d
    • tf.pad4d
    const x = tf.tensor1d([1, 2, 3, 4]);
    x.pad([[1, 2]]).print();

    Type Parameters

    Parameters

    • x: TensorLike | T

      The tensor to pad.

    • paddings: [number, number][]

      An array of length R (the rank of the tensor), where each element is a length-2 tuple of ints [padBefore, padAfter], specifying how much to pad along each dimension of the tensor.

    • Optional constantValue: number

      The pad value to use. Defaults to 0.

    Returns T

    Doc