14 #ifndef MLPACK_METHODS_ANN_LAYER_LEAKYRELU_HPP 15 #define MLPACK_METHODS_ANN_LAYER_LEAKYRELU_HPP 41 typename InputDataType = arma::mat,
42 typename OutputDataType = arma::mat
63 template<
typename InputType,
typename OutputType>
64 void Forward(
const InputType&& input, OutputType&& output);
75 template<
typename DataType>
76 void Backward(
const DataType&& input, DataType&& gy, DataType&& g);
84 OutputDataType
const&
Delta()
const {
return delta; }
86 OutputDataType&
Delta() {
return delta; }
89 double const&
Alpha()
const {
return alpha; }
91 double&
Alpha() {
return alpha; }
96 template<
typename Archive>
97 void serialize(Archive& ar,
const unsigned int );
106 double Fn(
const double x)
108 return std::max(x, alpha * x);
117 template<
typename eT>
118 void Fn(
const arma::Mat<eT>& x, arma::Mat<eT>& y)
120 y = arma::max(x, alpha * x);
129 double Deriv(
const double x)
131 return (x >= 0) ? 1 : alpha;
141 template<
typename InputType,
typename OutputType>
142 void Deriv(
const InputType& x, OutputType& y)
144 y.set_size(arma::size(x));
146 for (
size_t i = 0; i < x.n_elem; i++)
153 OutputDataType delta;
156 OutputDataType outputParameter;
166 #include "leaky_relu_impl.hpp" void serialize(Archive &ar, const unsigned int)
Serialize the layer.
LeakyReLU(const double alpha=0.03)
Create the LeakyReLU object using the specified parameters.
void Backward(const DataType &&input, DataType &&gy, DataType &&g)
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backw...
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Forward(const InputType &&input, OutputType &&output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
The LeakyReLU activation function, defined by.
OutputDataType const & Delta() const
Get the delta.
double const & Alpha() const
Get the non zero gradient.
OutputDataType const & OutputParameter() const
Get the output parameter.
double & Alpha()
Modify the non zero gradient.
OutputDataType & OutputParameter()
Modify the output parameter.
OutputDataType & Delta()
Modify the delta.