Function autograd::ops::square [] [src]

pub fn square(a: &Tensor) -> Tensor

Returns square of the input.

extern crate ndarray;
extern crate autograd as ag;

let mut ctx = ag::Context::new();
let ref a = ag::constant(ndarray::arr1(&[2., 3.]), &mut ctx);
let ref b = ag::square(a);
assert_eq!(
    b.eval(&mut ctx).as_slice().unwrap(),
    &[4., 9.]
);