12 #ifndef MLPACK_METHODS_ANN_LAYER_SOFTSHRINK_IMPL_HPP 13 #define MLPACK_METHODS_ANN_LAYER_SOFTSHRINK_IMPL_HPP 23 template<
typename InputDataType,
typename OutputDataType>
30 template<
typename InputDataType,
typename OutputDataType>
31 template<
typename InputType,
typename OutputType>
33 const InputType& input, OutputType& output)
35 output = (input > lambda) % (input - lambda) + (
36 input < -lambda) % (input + lambda);
39 template<
typename InputDataType,
typename OutputDataType>
40 template<
typename DataType>
42 const DataType& input, DataType& gy, DataType& g)
45 derivative = (arma::ones(arma::size(input)) - (input == 0));
49 template<
typename InputDataType,
typename OutputDataType>
50 template<
typename Archive>
55 ar(CEREAL_NVP(lambda));
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
Definition: softshrink_impl.hpp:32
SoftShrink(const double lambda=0.5)
Create Soft Shrink object using specified hyperparameter lambda.
Definition: softshrink_impl.hpp:24
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...
Definition: softshrink_impl.hpp:41
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: softshrink_impl.hpp:51