squeezingShape()
Returns a new squeezed shaped array.
Declaration
func squeezingShape() -> MLShapedArray<Scalar>Discussion
The new shape removes 1s in the original shape.
let original = MLShapedArray<Int32>(scalars: 0..., shape: [1, 2, 1, 2])
let squeezed = original.squeezingShape()
squeezed.shape // [2, 2]When all the dimensions of the original shape is one, the resultant shaped array is a scalar.
let original = MLShapedArray<Int32>(scalars: 42, shape: [1, 1])
let squeezed = original.squeezingShape()
squeezed.scalar // 42