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 
46 template <
47  typename InputDataType = arma::mat,
48  typename OutputDataType = arma::mat
49 >
51 {
52  public:
65  SoftShrink(const double lambda = 0.5);
66 
74  template<typename InputType, typename OutputType>
75  void Forward(const InputType& input, OutputType& output);
76 
86  template<typename DataType>
87  void Backward(const DataType& input,
88  DataType& gy,
89  DataType& g);
90 
92  OutputDataType const& OutputParameter() const { return outputParameter; }
94  OutputDataType& OutputParameter() { return outputParameter; }
95 
97  OutputDataType const& Delta() const { return delta; }
99  OutputDataType& Delta() { return delta; }
100 
102  double const& Lambda() const { return lambda; }
104  double& Lambda() { return lambda; }
105 
109  template<typename Archive>
110  void serialize(Archive& ar, const uint32_t /* version */);
111 
112  private:
114  OutputDataType delta;
115 
117  OutputDataType outputParameter;
118 
120  double lambda;
121 }; // class SoftShrink
122 
123 } // namespace ann
124 } // namespace mlpack
125 
126 // Include implementation.
127 #include "softshrink_impl.hpp"
128 
129 #endif
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: softshrink.hpp:94
Linear algebra utility functions, generally performed on matrices or vectors.
OutputDataType const & Delta() const
Get the delta.
Definition: softshrink.hpp:97
The core includes that mlpack expects; standard C++ includes and Armadillo.
double const & Lambda() const
Get the hyperparameter lambda.
Definition: softshrink.hpp:102
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Soft Shrink operator is defined as, .
Definition: softshrink.hpp:50
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: softshrink.hpp:92
OutputDataType & Delta()
Modify the delta.
Definition: softshrink.hpp:99
double & Lambda()
Modify the hyperparameter lambda.
Definition: softshrink.hpp:104
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.