mlpack 3.4.2
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
17namespace mlpack {
18namespace ann {
19
45template <
46 typename InputDataType = arma::mat,
47 typename OutputDataType = arma::mat
48>
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 const 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
The Hard Tanh activation function, defined by.
Definition: hard_tanh.hpp:50
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
HardTanH(const double maxValue=1, const double minValue=-1)
Create the HardTanH object using the specified parameters.
OutputDataType const & Delta() const
Get the delta.
Definition: hard_tanh.hpp:92
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: hard_tanh.hpp:87
double & MinValue()
Modify the minimum value.
Definition: hard_tanh.hpp:104
double const & MaxValue() const
Get the maximum value.
Definition: hard_tanh.hpp:97
double & MaxValue()
Modify the maximum value.
Definition: hard_tanh.hpp:99
double const & MinValue() const
Get the minimum value.
Definition: hard_tanh.hpp:102
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: hard_tanh.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: hard_tanh.hpp:94
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.