mlpack
|
Hard Shrink operator is defined as,. More...
#include <hardshrink.hpp>
Public Member Functions | |
HardShrink (const double lambda=0.5) | |
Create HardShrink object using specified hyperparameter lambda. More... | |
template<typename InputType , typename OutputType > | |
void | Forward (const InputType &input, OutputType &output) |
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activity forward through f. More... | |
template<typename DataType > | |
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 backwards through f. More... | |
OutputDataType const & | OutputParameter () const |
Get the output parameter. | |
OutputDataType & | OutputParameter () |
Modify the output parameter. | |
OutputDataType const & | Delta () const |
Get the delta. | |
OutputDataType & | Delta () |
Modify the delta. | |
double const & | Lambda () const |
Get the hyperparameter lambda. | |
double & | Lambda () |
Modify the hyperparameter lambda. | |
template<typename Archive > | |
void | serialize (Archive &ar, const uint32_t) |
Serialize the layer. | |
Hard Shrink operator is defined as,.
\begin{eqnarray*} f(x) &=& \begin{cases} x & : x > lambda \\ x & : x < -lambda \\ 0 & : otherwise. \end{cases} \\ f'(x) &=& \begin{cases} 1 & : x > lambda \\ 1 & : x < -lambda \\ 0 & : otherwise. \end{cases} \end{eqnarray*}
\(\lambda\) is set to 0.5 by default.
mlpack::ann::HardShrink< InputDataType, OutputDataType >::HardShrink | ( | const double | lambda = 0.5 | ) |
Create HardShrink object using specified hyperparameter lambda.
lambda | Is calculated by multiplying the noise level sigma of the input(noisy image) and a coefficient 'a' which is one of the training parameters. Default value of lambda is 0.5. |
void mlpack::ann::HardShrink< InputDataType, OutputDataType >::Backward | ( | const DataType & | input, |
DataType & | gy, | ||
DataType & | g | ||
) |
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backwards through f.
Using the results from the feed forward pass.
input | The propagated input activation f(x). |
gy | The backpropagated error. |
g | The calculated gradient. |
void mlpack::ann::HardShrink< InputDataType, OutputDataType >::Forward | ( | const InputType & | input, |
OutputType & | output | ||
) |
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activity forward through f.
input | Input data used for evaluating the Hard Shrink function. |
output | Resulting output activation. |