diff --git a/src/mlpack/methods/ann/activation_functions/softplus_function.hpp b/src/mlpack/methods/ann/activation_functions/softplus_function.hpp index dd5875ff83..395e99db99 100644 --- a/src/mlpack/methods/ann/activation_functions/softplus_function.hpp +++ b/src/mlpack/methods/ann/activation_functions/softplus_function.hpp @@ -62,13 +62,11 @@ class SoftplusFunction * @param x Input data. * @param y The resulting output activation. */ - template - static void Fn(const InputVecType& x, OutputVecType& y) + template + static void Fn(const InputType& x, OutputType& y) { y = x; - - for (size_t i = 0; i < x.n_elem; i++) - y(i) = Fn(x(i)); + y.transform([](double val) {return (Fn(val));} ); } /** @@ -88,8 +86,8 @@ class SoftplusFunction * @param y Input activations. * @param x The resulting derivatives. */ - template - static void Deriv(const InputVecType& y, OutputVecType& x) + template + static void Deriv(const InputType& y, OutputType& x) { x = 1.0 / (1 + arma::exp(-y)); } @@ -111,13 +109,11 @@ class SoftplusFunction * @param y Input data. * @param x The resulting inverse of the input data. */ - template - static void Inv(const InputVecType& y, OutputVecType& x) + template + static void Inv(const InputType& y, OutputType& x) { x = y; - - for (size_t i = 0; i < y.n_elem; i++) - x(i) = Inv(y(i)); + x.transform([](double val) {return (Inv(val));} ); } }; // class SoftplusFunction