Update src/mlpack/methods/ann/layer/c_relu_impl.hpp
Co-authored-by: Ryan Curtin <ryan@ratml.org>
This commit is contained in:
co-authored by
Ryan Curtin
parent
f6d78abf42
commit
d91c5f0f31
@@ -87,10 +87,12 @@ void CReLUType<MatType>::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<typename MatType>
|
||||
|
||||
Reference in New Issue
Block a user