Open
Description
Hello
i get an type mismatch error when in do
let mut c_post: Array1<f32> = a.c.mapv(|x| x.tanh());
a.h = &a.o_gate * c_post;
Edit: o_gate has the type Array1<f32>
Error
error[E0271]: type mismatch resolving `<f32 as std::ops::Mul<ndarray::ArrayBase<ndarray::OwnedRepr<f32>, ndarray::dimension::dim::Dim<[usize; 1]>>>>::Output == f32`
--> src/main.rs:188:25
|
188 | a.h = &a.o_gate * c_post;
| ^ expected struct `ndarray::ArrayBase`, found f32
|
= note: expected type `ndarray::ArrayBase<ndarray::OwnedRepr<f32>, ndarray::dimension::dim::Dim<[usize; 1]>>`
found type `f32`
= note: required because of the requirements on the impl of `std::ops::Mul<ndarray::ArrayBase<ndarray::OwnedRepr<f32>, ndarray::dimension::dim::Dim<[usize; 1]>>>` for `&ndarray::ArrayBase<ndarray::OwnedRepr<f32>, ndarray::dimension::dim::Dim<[usize; 1]>>`
error[E0277]: the trait bound `ndarray::ArrayBase<ndarray::OwnedRepr<f32>, ndarray::dimension::dim::Dim<[usize; 1]>>: ndarray::impl_ops::ScalarOperand` is not satisfied
--> src/main.rs:188:25
|
188 | a.h = &a.o_gate * c_post;
| ^ the trait `ndarray::impl_ops::ScalarOperand` is not implemented for `ndarray::ArrayBase<ndarray::OwnedRepr<f32>, ndarray::dimension::dim::Dim<[usize; 1]>>`
|
= note: required because of the requirements on the impl of `std::ops::Mul<ndarray::ArrayBase<ndarray::OwnedRepr<f32>, ndarray::dimension::dim::Dim<[usize; 1]>>>` for `&ndarray::ArrayBase<ndarray::OwnedRepr<f32>, ndarray::dimension::dim::Dim<[usize; 1]>>`
i think it tries to do a scalar operation
When i don't try to do it inplace it works
let mut c_post: Array1<f32> = a.c.mapv(|x| x.tanh());
a.h = &a.o_gate * &c_post;
We use inplace operations when concerned about the memory usage right?
Metadata
Metadata
Assignees
Labels
No labels