Contents

expandingShape(at:)

Returns a new shaped array with expanded dimensions

Declaration

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

Discussion

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

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

See Also

Shaping the array slice