-
-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autodiff
: add support for nalgebra matrices/vectors.
#64
Comments
Opps, just realised there is an issue for it and you assigned to yourself. This is my blocker of #63 and I'm trying to fix it as well.
You can see my progress in main...WenqingZong:RustQuant:wenqing/neural-networks Currently the code doesn't compile due to an error which I'm not sure how to fix, was meant to ask for your help but found you are working on it as well. The Problem: |
If I recall correctly, using // Original
let z = x + y;
// Using `Rc`
let z = x.clone() + y.clone(); Which I think is not user friendly. Is this the problem you had ? |
Hmmm, ok, forget about the |
I could try |
superb |
I tried briefly this morning using I can maybe take a closer look tomorrow. |
The trouble with Component-wise multiplication works fine, but can't do matrix multiplication I think. #[cfg(test)]
mod test_ndarray {
#[test]
fn test_component_mul() {
let g = crate::autodiff::Graph::new();
let (a, b, c, d) = (g.var(1.), g.var(2.), g.var(3.), g.var(4.));
let (e, f, g, h) = (g.var(5.), g.var(6.), g.var(7.), g.var(8.));
// a = [[1, 2],
// [3, 4]]
// b = [[5, 6],
// [7, 8]]
let a = ndarray::array![[a, b], [c, d]];
let b = ndarray::array![[e, f], [g, h]];
// COMPONENT-WISE MULTIPLICATION
// c = [[5 , 12],
// [21, 32]]
let c = a * b; // <--- This works fine.
let c_values = c.map(|x| x.value);
let c_expected = ndarray::array![[5., 12.], [21., 32.]];
// MATRIX MULTIPLICATION
// let dot = a.dot(&b); // <--- This does not work.
assert_eq!(c, c_expected);
println!("c: {:?}", c);
println!("c_values: {:?}", c_values);
println!("c_expected: {:?}", c_expected);
}
} |
It would work I think if I could |
Would a global, static graph variable solve that? |
I tried that earlier but it required unsafe and then I still got a lifetime issue trying to implement the matrix multiplication. You can see it in the latest commit in the ndarray.rs file. |
RustQuant::autodiff
: add support for nalgebra matrices/vectors. autodiff
: add support for nalgebra matrices/vectors.
No description provided.
The text was updated successfully, but these errors were encountered: