From 214dc882b8650383bb7bd2eae0b20601883e322c Mon Sep 17 00:00:00 2001 From: nishantkr18 Date: Tue, 12 May 2020 17:37:14 +0530 Subject: [PATCH] applied suggested changes --- .../softplus_function.hpp | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/mlpack/methods/ann/activation_functions/softplus_function.hpp b/src/mlpack/methods/ann/activation_functions/softplus_function.hpp index a8a0cf680c..0a60e88dd7 100644 --- a/src/mlpack/methods/ann/activation_functions/softplus_function.hpp +++ b/src/mlpack/methods/ann/activation_functions/softplus_function.hpp @@ -52,20 +52,9 @@ class SoftplusFunction static double Fn(const double x) { const double val = std::log(1 + std::exp(x)); - if (x < DBL_MAX) - { - if (x > -DBL_MAX) - { - if (std::isfinite(val)) - return val; - else - return x; - } - else - return 0; - } - else - return 1.0; + if (std::isfinite(val)) + return val; + return x; } /** @@ -115,15 +104,9 @@ class SoftplusFunction static double Inv(const double y) { const double val = std::log(std::exp(y) - 1); - if (y > 0) - { - if (std::isfinite(val)) - return val; - else - return y; - } - else - return 0; + if (std::isfinite(val)) + return val; + return y; } /**