Contents

expandingShape(at:)

Returns a new shaped array with expanded dimensions.

Declaration

func expandingShape(at axis: Int) -> MLShapedArray<Scalar>

Discussion

The shape of the new MLShapedArray gets a new dimension of 1 at the specified axis index.

let original = MLShapedArray<Int32>(scalars: 0..., shape: [2, 3])
let expanded = original.expandingShape(at: 0)
expanded.shape // [1, 2, 3]

See Also

Shaping the array