[][src]Function autograd::ops::clip

pub fn clip<T: Float, A: AsRef<Tensor<T>>>(x: A, min: T, max: T) -> Tensor<T>

Limits all elements of x so as to be within [min, max]

extern crate ndarray;
extern crate autograd as ag;

let ref x = ag::constant(ndarray::arr1(&[2., 4., 6.]));
let ref y = ag::clip(x, 3., 5.);

assert_eq!(y.eval(&[]), Some(ndarray::arr1(&[3., 4., 5.]).into_dyn()));