14 #ifndef MLPACK_METHODS_ANN_LAYER_LEAKYRELU_IMPL_HPP 15 #define MLPACK_METHODS_ANN_LAYER_LEAKYRELU_IMPL_HPP 23 template<
typename InputDataType,
typename OutputDataType>
25 const double alpha) : alpha(alpha)
30 template<
typename InputDataType,
typename OutputDataType>
31 template<
typename InputType,
typename OutputType>
33 const InputType& input, OutputType& output)
35 output = arma::max(input, alpha * input);
38 template<
typename InputDataType,
typename OutputDataType>
39 template<
typename DataType>
41 const DataType& input,
const DataType& gy, DataType& g)
44 derivative.set_size(arma::size(input));
45 for (
size_t i = 0; i < input.n_elem; ++i)
46 derivative(i) = (input(i) >= 0) ? 1 : alpha;
51 template<
typename InputDataType,
typename OutputDataType>
52 template<
typename Archive>
57 ar(CEREAL_NVP(alpha));
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
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: leaky_relu_impl.hpp:32
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: leaky_relu_impl.hpp:53
LeakyReLU(const double alpha=0.03)
Create the LeakyReLU object using the specified parameters.
Definition: leaky_relu_impl.hpp:24
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: leaky_relu_impl.hpp:40