mlpack 3.4.2
leaky_relu.hpp
Go to the documentation of this file.
1
14#ifndef MLPACK_METHODS_ANN_LAYER_LEAKYRELU_HPP
15#define MLPACK_METHODS_ANN_LAYER_LEAKYRELU_HPP
16
17#include <mlpack/prereqs.hpp>
18
19namespace mlpack {
20namespace ann {
21
40template <
41 typename InputDataType = arma::mat,
42 typename OutputDataType = arma::mat
43>
45{
46 public:
54 LeakyReLU(const double alpha = 0.03);
55
63 template<typename InputType, typename OutputType>
64 void Forward(const InputType& input, OutputType& output);
65
75 template<typename DataType>
76 void Backward(const DataType& input, const DataType& gy, DataType& g);
77
79 OutputDataType const& OutputParameter() const { return outputParameter; }
81 OutputDataType& OutputParameter() { return outputParameter; }
82
84 OutputDataType const& Delta() const { return delta; }
86 OutputDataType& Delta() { return delta; }
87
89 double const& Alpha() const { return alpha; }
91 double& Alpha() { return alpha; }
92
96 template<typename Archive>
97 void serialize(Archive& ar, const unsigned int /* version */);
98
99 private:
101 OutputDataType delta;
102
104 OutputDataType outputParameter;
105
107 double alpha;
108}; // class LeakyReLU
109
110} // namespace ann
111} // namespace mlpack
112
113// Include implementation.
114#include "leaky_relu_impl.hpp"
115
116#endif
The LeakyReLU activation function, defined by.
Definition: leaky_relu.hpp:45
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
OutputDataType const & Delta() const
Get the delta.
Definition: leaky_relu.hpp:84
double & Alpha()
Modify the non zero gradient.
Definition: leaky_relu.hpp:91
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: leaky_relu.hpp:79
LeakyReLU(const double alpha=0.03)
Create the LeakyReLU object using the specified parameters.
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: leaky_relu.hpp:81
double const & Alpha() const
Get the non zero gradient.
Definition: leaky_relu.hpp:89
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...
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Delta()
Modify the delta.
Definition: leaky_relu.hpp:86
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.