jax-js
    Preparing search index...

    Function expandDims

    • Expand the shape of an array by inserting new axes of length 1.

      Parameters

      • a: ArrayLike

        Input array.

      • axis: number | number[]

        Position(s) in the expanded axes where the new axis (or axes) is placed. Can be a single integer or an array of integers.

      Returns Array

      Array with the number of dimensions increased.

      const x = np.array([1, 2]);
      np.expandDims(x, 0); // Shape [1, 2]
      np.expandDims(x, 1); // Shape [2, 1]
      np.expandDims(x, [0, 2]); // Shape [1, 2, 1]