• Checks the input tensor mathes the given shape.

    Given an input tensor, returns a new tensor with the same values as the input tensor with shape shape.

    The method supports the null value in tensor. It will still check the shapes, and null is a placeholder.

    const x = tf.tensor1d([1, 2, 3, 4]);
    const y = tf.tensor1d([1, null, 3, 4]);
    const z = tf.tensor2d([1, 2, 3, 4], [2,2]);
    tf.ensureShape(x, [4]).print();
    tf.ensureShape(y, [4]).print();
    tf.ensureShape(z, [null, 2]).print();

    Type Parameters

    • R extends Rank

    Parameters

    • x: Tensor<Rank>

      The input tensor to be ensured.

    • shape: ShapeMap[R]

      A TensorShape representing the shape of this tensor, an array or null.

    Returns Tensor

    Doc

Generated using TypeDoc