Contents

mean(keepRank:)

Returns the mean along all axes.

Declaration

func mean(keepRank: Bool = false) -> MLTensor

Parameters

  • keepRank:

    A Boolean indicating whether to keep the reduced axes or not. The default value is false.

Return Value

The reduced tensor.

Discussion

For example:

let x = MLTensor(shape: [3, 2], scalars: [2, 3, 4, 5, 6, 7], scalarType: Float.self)
let y = x.mean()
y.shape // is []
await y.shapedArray(of: Float.self) // is [4.5]

See Also

Accessing the minimum, maximum and mean