Skip to content

Commit

Permalink
replaced ArrayBase::outer_iter{_mut} calls with calls to ArrayBase::g…
Browse files Browse the repository at this point in the history
…enrows{_mut}
  • Loading branch information
Robbepop committed Sep 4, 2017
1 parent 25aadd0 commit 335822c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/neural_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl FullyConnectedLayer {
// Could profit greatly from vectorization and builtin library solutions for this
// kind of operation w.r.t. performance gains.
// =================================================================================
Zip::from(&mut self.outputs).and(self.weights.outer_iter()).apply(|output, weights| {
Zip::from(&mut self.outputs).and(self.weights.genrows()).apply(|output, weights| {
let s = weights.len();
*output = act.base(weights.slice(s![..-1]).dot(&input) + weights[s-1]);
});
Expand Down Expand Up @@ -236,7 +236,7 @@ impl FullyConnectedLayer {
debug_assert_eq!(prev.weights.rows(), prev.count_gradients() - 1);
debug_assert_eq!(prev.weights.cols(), self.count_gradients());

multizip((prev.weights.outer_iter(), prev.gradients.iter()))
multizip((prev.weights.genrows(), prev.gradients.iter()))
.foreach(|(prev_weights_row, prev_gradient)| {
multizip((self.gradients.iter_mut(), prev_weights_row.iter()))
.foreach(|(gradient, weight)| *gradient += weight * prev_gradient)
Expand All @@ -261,8 +261,8 @@ impl FullyConnectedLayer {
// ==================================================================== //
// OLD
// ==================================================================== //
multizip((self.weights.outer_iter_mut(),
self.delta_weights.outer_iter_mut(),
multizip((self.weights.genrows_mut(),
self.delta_weights.genrows_mut(),
self.gradients.iter()))
.foreach(|(mut weights_row, mut delta_weights_row, gradient)| {
multizip((prev_outputs.iter().chain(iter::once(&1.0)),
Expand Down

0 comments on commit 335822c

Please sign in to comment.