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"