Contents

clamped(to:)

Clamps all elements to the given lower and upper bounds, inclusively.

Declaration

func clamped(to bounds: ClosedRange<Float>) -> MLTensor

Discussion

For example:

let x = MLTensor([-1.0, 1.0, 2.0])
let y = x.clamped(to: 0...1)
await y.shapedArray(of: Float.self) // is [0.0, 1.0, 1.0]

See Also

Clamping and concatenating