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);
101 template<
typename Archive>
102 void Serialize(Archive& ar,
const unsigned int );
111 double Fn(
const double x)
113 return std::max(x,
alpha * x);
122 template<
typename eT>
123 void Fn(
const arma::Mat<eT>& x, arma::Mat<eT>& y)
125 y = arma::max(x,
alpha * x);
136 return (x >= 0) ? 1 :
alpha;
146 template<
typename InputType,
typename OutputType>
147 void Deriv(
const InputType& x, OutputType& y)
151 for (
size_t i = 0; i < x.n_elem; i++)
175 #include "leaky_relu_impl.hpp" void Forward(const InputType &&input, OutputType &&output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
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...
OutputDataType outputParameter
Locally-stored output parameter object.
void Serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & OutputParameter()
Modify the output parameter.
Linear algebra utility functions, generally performed on matrices or vectors.
double const & Alpha() const
Get the non zero gradient.
The core includes that mlpack expects; standard C++ includes and Armadillo.
The LeakyReLU activation function, defined by.
InputDataType & InputParameter()
Modify the input parameter.
void Fn(const arma::Mat< eT > &x, arma::Mat< eT > &y)
Computes the Leaky ReLU function using a dense matrix as input.
OutputDataType & Delta()
Modify the delta.
OutputDataType const & OutputParameter() const
Get the output parameter.
LeakyReLU(const double alpha=0.03)
Create the LeakyReLU object using the specified parameters.
OutputDataType delta
Locally-stored delta object.
OutputDataType const & Delta() const
Get the delta.
double & Alpha()
Modify the non zero gradient.
double alpha
Leakyness Parameter in the range 0 <alpha< 1.
double Fn(const double x)
Computes the LeakReLU function.
InputDataType inputParameter
Locally-stored input parameter object.
InputDataType const & InputParameter() const
Get the input parameter.
void Deriv(const InputType &x, OutputType &y)
Computes the first derivative of the LeakyReLU function.
double Deriv(const double x)
Computes the first derivative of the LeakyReLU function.