[][src]Function autograd::ops::add_n

pub fn add_n<T: Float>(xs: &[&Tensor<T>]) -> Tensor<T>

Adds all input tensors, element-wise.

All the input tensors must have same shapes.

extern crate ndarray;
extern crate autograd as ag;

let ref a = ag::ones(&[2, 2]);
let ref b = ag::ones(&[2, 2]);
let ref c = ag::ones(&[2, 2]);
let ref d = ag::add_n(&[a, b, c]);

assert_eq!(d.eval(&[]).as_ref().unwrap().shape(), &[2, 2]);
assert_eq!(d.eval(&[]), Some(ndarray::arr2(&[[3., 3.], [3., 3.]]).into_dyn()));