Contents

reshaped(to:)

Reshape to the specified shape.

Declaration

func reshaped(to newShape: [Int]) -> MLTensor

Parameters

  • newShape:

    The new shape of the array. The number of scalars matches the new shape.

Discussion

For example:

let x = MLTensor(shape: [2], scalars: [1, 2], scalarType: Float.self)
let y = x.reshaped(at: [1, 2, 1])
y.shape // is [1, 2, 1]

See Also

Reshaping the tensor