18 #ifndef MLPACK_METHODS_ANN_LAYER_ELU_IMPL_HPP 19 #define MLPACK_METHODS_ANN_LAYER_ELU_IMPL_HPP 29 template<
typename InputDataType,
typename OutputDataType>
31 alpha(1.6732632423543774),
32 lambda(1.0507009873554802),
40 template<
typename InputDataType,
typename OutputDataType>
49 template<
typename InputDataType,
typename OutputDataType>
50 template<
typename InputType,
typename OutputType>
52 const InputType& input, OutputType& output)
54 output = arma::ones<OutputDataType>(arma::size(input));
55 for (
size_t i = 0; i < input.n_elem; ++i)
57 if (input(i) < DBL_MAX)
59 output(i) = (input(i) > 0) ? lambda * input(i) : lambda *
60 alpha * (std::exp(input(i)) - 1);
66 derivative.set_size(arma::size(input));
67 for (
size_t i = 0; i < input.n_elem; ++i)
69 derivative(i) = (input(i) > 0) ? lambda : output(i) +
75 template<
typename InputDataType,
typename OutputDataType>
76 template<
typename DataType>
78 const DataType& ,
const DataType& gy, DataType& g)
83 template<
typename InputDataType,
typename OutputDataType>
84 template<
typename Archive>
89 ar(CEREAL_NVP(alpha));
90 ar(CEREAL_NVP(lambda));
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
Definition: elu_impl.hpp:51
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: elu_impl.hpp:85
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
ELU()
Create the ELU object.
Definition: elu_impl.hpp:30
void Backward(const DataType &input, const DataType &gy, DataType &g)
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backw...
Definition: elu_impl.hpp:77