-
pub fn back_propagate(&self, layer_outputs: &Vec<Vector>, expected: &Vector) -> Vector {
let mut last_error = expected;
for (i, weights) in self.weights.iter().enumerate() {
last_error = weights.dot(&last_error); // the trait bound `ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>: Dot<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>` is not satisfied
// ...
}
} in this function, I get this error: error[E0277]: the trait bound `ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>: Dot<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>` is not satisfied
--> src/brain.rs:23:40
|
23 | last_error = (weights).dot(&last_error);
| --- ^^^^^^^^^^^ the trait `Dot<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>` is not implemented for `ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `Dot<Rhs>`:
<ArrayBase<S, Dim<[usize; 1]>> as Dot<ArrayBase<S2, Dim<[usize; 1]>>>>
<ArrayBase<S, Dim<[usize; 1]>> as Dot<ArrayBase<S2, Dim<[usize; 2]>>>>
<ArrayBase<S, Dim<[usize; 2]>> as Dot<ArrayBase<S2, Dim<[usize; 1]>>>>
<ArrayBase<S, Dim<[usize; 2]>> as Dot<ArrayBase<S2, Dim<[usize; 2]>>>>
note: required by a bound in `linalg::impl_linalg::<impl ArrayBase<S, Dim<[usize; 2]>>>::dot`
--> /home/censored/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.15.6/src/linalg/impl_linalg.rs:255:15
|
253 | pub fn dot<Rhs>(&self, rhs: &Rhs) -> <Self as Dot<Rhs>>::Output
| --- required by a bound in this associated function
254 | where
255 | Self: Dot<Rhs>,
| ^^^^^^^^ required by this bound in `linalg::impl_linalg::<impl ArrayBase<S, Dim<[usize; 2]>>>::dot` I have no idea what the difference would be between what im trying to do:
and the implementation (relevant docs):
The only thing I can see is that the first one has a reference to an ArrayBase but the dot method on the matrix only accepts a reference as rhs argument so if that's the case, then the question is how should i fix it? ~~Also I'm just assuming f64 implements the LinalgScalar trait, but I don't know how to prove that hypothesis. ~~ edit: why markdown no worky, tho hypothesis confirmed |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I fixed it this line should have been derefenced like so: let mut last_error = *expected; sorry but the rust error message really wasn't to much help |
Beta Was this translation helpful? Give feedback.
I fixed it this line should have been derefenced like so:
sorry but the rust error message really wasn't to much help