mlpack 3.4.2
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
21namespace mlpack {
22namespace ann {
23
46template <
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 unsigned int /* 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
Soft Shrink operator is defined as,.
Definition: softshrink.hpp:51
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 & Delta() const
Get the delta.
Definition: softshrink.hpp:97
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 & Lambda()
Modify the hyperparameter lambda.
Definition: softshrink.hpp:104
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: softshrink.hpp:92
double const & Lambda() const
Get the hyperparameter lambda.
Definition: softshrink.hpp:102
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: softshrink.hpp:94
SoftShrink(const double lambda=0.5)
Create Soft Shrink object using specified hyperparameter lambda.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Delta()
Modify the delta.
Definition: softshrink.hpp:99
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.