• Returns a tf.Tensor that has expanded rank, by inserting a dimension into the tensor's shape.

    const x = tf.tensor1d([1, 2, 3, 4]);
    const axis = 1;
    x.expandDims(axis).print();

    Type Parameters

    Parameters

    • x: TensorLike | Tensor<Rank>

      The input tensor whose dimensions are to be expanded.

    • Optional axis: number

      The dimension index at which to insert shape of 1. Defaults to 0 (the first dimension).

    Returns T

    Doc