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 
19 namespace mlpack {
20 namespace ann {
21 
40 template <
41  typename InputDataType = arma::mat,
42  typename OutputDataType = arma::mat
43 >
44 class LeakyReLU
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 
94  size_t WeightSize() const { return 0; }
95 
99  template<typename Archive>
100  void serialize(Archive& ar, const uint32_t /* version */);
101 
102  private:
104  OutputDataType delta;
105 
107  OutputDataType outputParameter;
108 
110  double alpha;
111 }; // class LeakyReLU
112 
113 } // namespace ann
114 } // namespace mlpack
115 
116 // Include implementation.
117 #include "leaky_relu_impl.hpp"
118 
119 #endif
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...
LeakyReLU(const double alpha=0.03)
Create the LeakyReLU object using the specified parameters.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
The LeakyReLU activation function, defined by.
Definition: leaky_relu.hpp:44
OutputDataType const & Delta() const
Get the delta.
Definition: leaky_relu.hpp:84
double const & Alpha() const
Get the non zero gradient.
Definition: leaky_relu.hpp:89
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
size_t WeightSize() const
Get size of weights.
Definition: leaky_relu.hpp:94
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 & OutputParameter() const
Get the output parameter.
Definition: leaky_relu.hpp:79
double & Alpha()
Modify the non zero gradient.
Definition: leaky_relu.hpp:91
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: leaky_relu.hpp:81
OutputDataType & Delta()
Modify the delta.
Definition: leaky_relu.hpp:86