From 43afb1d4caad3fcf977883c4dad103bdda0a185c Mon Sep 17 00:00:00 2001 From: Ahmed Taei Date: Tue, 20 Jun 2017 21:15:23 -0700 Subject: [PATCH] Make sure Elu alpha is strictly positive Reviewed By: Yangqing Differential Revision: D5289483 fbshipit-source-id: 96223304e4b1278595bae5ed137b5b80b7f8f521 --- caffe2/operators/elu_op.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/caffe2/operators/elu_op.cc b/caffe2/operators/elu_op.cc index b646b0bb3db4fb..db36584b52e84b 100644 --- a/caffe2/operators/elu_op.cc +++ b/caffe2/operators/elu_op.cc @@ -8,6 +8,8 @@ template <> bool EluOp::RunOnDevice() { auto& X = Input(0); auto* Y = Output(0); + // Otherwise inplace gradient and Elu dosen't make sense. + CAFFE_ENFORCE_GE(alpha_, 0); Y->ResizeLike(X); const auto* Xdata = X.template data(); auto* Ydata = Y->template mutable_data();