Function autograd::ops::constant [] [src]

pub fn constant<T>(arr: Array<f32, T>, ctx: &mut Context) -> Tensor where
    T: Dimension

Creates a constant tensor.

Same as Context::constant.

extern crate ndarray;
extern crate autograd as ag;

let mut ctx = ag::Context::new();
let arr = ndarray::arr1(&[0., 0., 0.]);
let ref con = ag::constant(arr.clone(), &mut ctx);
assert_eq!(con.eval(&mut ctx), arr.into_dyn())