diff --git a/src/mlpack/methods/ann/layer/c_relu_impl.hpp b/src/mlpack/methods/ann/layer/c_relu_impl.hpp index c6b668a0ef..a687af81c8 100644 --- a/src/mlpack/methods/ann/layer/c_relu_impl.hpp +++ b/src/mlpack/methods/ann/layer/c_relu_impl.hpp @@ -87,10 +87,12 @@ void CReLUType::Backward( const MatType& gy, MatType& g) { - // while it doesn't really matter if what we choose for the gradient at exactly 0, since we have the - // discontinuity from -1 to 1 between 0- and 0+, it seems cleaner to set the gradient at x=0 to 0 - // instead of picking either +1 or -1. - g = gy.rows(0, input.n_rows-1) % (input > 0) - gy.rows(input.n_rows, input.n_rows * 2 - 1) % (input < 0); + // While it doesn't really matter if what we choose for the gradient at + // exactly 0, since we have the discontinuity from -1 to 1 between 0- and 0+, + // it seems cleaner to set the gradient at x=0 to 0 instead of picking either + // +1 or -1. + g = gy.rows(0, input.n_rows - 1) % (input > 0) - + gy.rows(input.n_rows, input.n_rows * 2 - 1) % (input < 0); } template