raskr / rust-autograd

Tensors and differentiable operations (like TensorFlow) in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"ndarray" and "autograd::ndarray"

laocaoshilaocao opened this issue · comments

Hi, i am a beginner of this interesting rust deep learning library.
When i try to run several basic examples using ndarray, i found that always has a compiler error saying i should use autograd::ndarray. Code and error are shown as follow:

    ag::with(|g| {
        let x = g.placeholder(&[-1,-1]);
        let value = array![[1., 1.]];  
        println!("{:?}", x.eval(&[x.given(value.view())]).unwrap()); 
    });
error[E0308]: mismatched types
  --> src\main.rs:14:43
   |
14 |         println!("{:?}", x.eval(&[x.given(value.view())]).unwrap());
   |                                           ^^^^^^^^^^^^ expected struct `autograd::ndarray::ArrayBase`, found struct `ndarray::ArrayBase`
   |
   = note: expected struct `autograd::ndarray::ArrayBase<autograd::ndarray::ViewRepr<&_>, _>`
              found struct `ndarray::ArrayBase<ndarray::ViewRepr<&{float}>, ndarray::Dim<[usize; 2]>>`
   = note: perhaps two different versions of crate `ndarray` are being used?

Is that compulsory to use ag::ndarray::array![[1., 1.]] instead of array![[1., 1.]] in this kind of cases?
Thanks for your help.

Okay, i found that happens because i used the version 0.15.1 of ndarray.
After i changed the dependence version to 0.12.1 everything works.

Thank you for the report, yes, ndarray is re-exported to avoid this problem for now.