mlpack  3.1.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
softshrink.hpp
Go to the documentation of this file.
1 
16 #ifndef MLPACK_METHODS_ANN_LAYER_SOFTSHRINK_HPP
17 #define MLPACK_METHODS_ANN_LAYER_SOFTSHRINK_HPP
18 
19 #include <mlpack/prereqs.hpp>
20 
21 namespace mlpack {
22 namespace ann {
23 
48 template <
49  typename InputDataType = arma::mat,
50  typename OutputDataType = arma::mat
51 >
53 {
54  public:
67  SoftShrink(const double lambda = 0.5);
68 
76  template<typename InputType, typename OutputType>
77  void Forward(const InputType& input, OutputType& output);
78 
88  template<typename DataType>
89  void Backward(const DataType& input,
90  DataType& gy,
91  DataType& g);
92 
94  OutputDataType const& OutputParameter() const { return outputParameter; }
96  OutputDataType& OutputParameter() { return outputParameter; }
97 
99  OutputDataType const& Delta() const { return delta; }
101  OutputDataType& Delta() { return delta; }
102 
104  double const& Lambda() const { return lambda; }
106  double& Lambda() { return lambda; }
107 
111  template<typename Archive>
112  void serialize(Archive& ar, const unsigned int /* version */);
113 
114  private:
116  OutputDataType delta;
117 
119  OutputDataType outputParameter;
120 
122  double lambda;
123 }; // class SoftShrink
124 
125 } // namespace ann
126 } // namespace mlpack
127 
128 // Include implementation.
129 #include "softshrink_impl.hpp"
130 
131 #endif
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: softshrink.hpp:96
OutputDataType const & Delta() const
Get the delta.
Definition: softshrink.hpp:99
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: softshrink.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...
Soft Shrink operator is defined as, .
Definition: softshrink.hpp:52
double const & Lambda() const
Get the hyperparameter lambda.
Definition: softshrink.hpp:104
OutputDataType & Delta()
Modify the delta.
Definition: softshrink.hpp:101
double & Lambda()
Modify the hyperparameter lambda.
Definition: softshrink.hpp:106
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...
SoftShrink(const double lambda=0.5)
Create Soft Shrink object using specified hyperparameter lambda.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.