[−][src]Function autograd::ops::variable
pub fn variable<T: Float, D: Dimension>(arr: Array<T, D>) -> Tensor<T>
Creates a shared variable tensor from an ndarray.
A shared variable can be mutated with gradient descent methods
implemented in autograd::gradient_descent_ops
.
For the usages, see https://github.com/perrier1034/rust-autograd/tree/master/examples.
extern crate ndarray; extern crate autograd as ag; let ref x: ag::Tensor<f64> = ag::variable(ndarray::arr1(&[2.])); let ref y: ag::Tensor<f64> = 3. * x; assert_eq!(6., y.eval(&[]).unwrap()[0]);