pub fn abs<T: Tensor<Dtype = f32>>(t: T) -> T
Expand description

The absolute value (abs) computes |x|

The derivative is -1.0 for x < 0, 0 for x == 0, and 1.0 for x > 0.

Examples:

let t = Tensor1D::new([-1.0, 0.0, 1.0, 2.0]);

// use function version
let r = abs(t.clone());

// or the tensor method!
let r2 = t.abs();