hard_tanh.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_LAYER_HARD_TANH_HPP
13 #define MLPACK_METHODS_ANN_LAYER_HARD_TANH_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace ann {
19 
45 template <
46  typename InputDataType = arma::mat,
47  typename OutputDataType = arma::mat
48 >
49 class HardTanH
50 {
51  public:
60  HardTanH(const double maxValue = 1, const double minValue = -1);
61 
69  template<typename InputType, typename OutputType>
70  void Forward(const InputType&& input, OutputType&& output);
71 
81  template<typename DataType>
82  void Backward(const DataType&& input,
83  DataType&& gy,
84  DataType&& g);
85 
87  OutputDataType const& OutputParameter() const { return outputParameter; }
89  OutputDataType& OutputParameter() { return outputParameter; }
90 
92  OutputDataType const& Delta() const { return delta; }
94  OutputDataType& Delta() { return delta; }
95 
97  double const& MaxValue() const { return maxValue; }
99  double& MaxValue() { return maxValue; }
100 
102  double const& MinValue() const { return minValue; }
104  double& MinValue() { return minValue; }
105 
109  template<typename Archive>
110  void serialize(Archive& ar, const unsigned int /* version */);
111 
112  private:
114  OutputDataType delta;
115 
117  OutputDataType outputParameter;
118 
120  double maxValue;
121 
123  double minValue;
124 }; // class HardTanH
125 
126 } // namespace ann
127 } // namespace mlpack
128 
129 // Include implementation.
130 #include "hard_tanh_impl.hpp"
131 
132 #endif
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...
double & MaxValue()
Modify the maximum value.
Definition: hard_tanh.hpp:99
.hpp
Definition: add_to_po.hpp:21
double & MinValue()
Modify the minimum value.
Definition: hard_tanh.hpp:104
void Forward(const InputType &&input, OutputType &&output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
double const & MaxValue() const
Get the maximum value.
Definition: hard_tanh.hpp:97
The core includes that mlpack expects; standard C++ includes and Armadillo.
double const & MinValue() const
Get the minimum value.
Definition: hard_tanh.hpp:102
The Hard Tanh activation function, defined by.
Definition: hard_tanh.hpp:49
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: hard_tanh.hpp:89
OutputDataType const & Delta() const
Get the delta.
Definition: hard_tanh.hpp:92
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Delta()
Modify the delta.
Definition: hard_tanh.hpp:94
HardTanH(const double maxValue=1, const double minValue=-1)
Create the HardTanH object using the specified parameters.
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: hard_tanh.hpp:87