13 #ifndef MLPACK_METHODS_ANN_LAYER_REPARAMETRIZATION_HPP 14 #define MLPACK_METHODS_ANN_LAYER_REPARAMETRIZATION_HPP 19 #include "../activation_functions/softplus_function.hpp" 52 typename InputDataType = arma::mat,
53 typename OutputDataType = arma::mat
55 class Reparametrization
70 const bool stochastic =
true,
71 const bool includeKl =
true,
72 const double beta = 1);
82 void Forward(
const arma::Mat<eT>&& input, arma::Mat<eT>&& output);
94 void Backward(
const arma::Mat<eT>&& input,
104 OutputDataType
const&
Delta()
const {
return delta; }
106 OutputDataType&
Delta() {
return delta; }
119 return -0.5 * beta * arma::accu(2 * arma::log(stdDev) - arma::pow(stdDev, 2)
120 - arma::pow(mean, 2) + 1) / mean.n_cols;
126 template<
typename Archive>
127 void serialize(Archive& ar,
const unsigned int );
143 OutputDataType delta;
146 OutputDataType gaussianSample;
153 OutputDataType preStdDev;
156 OutputDataType stdDev;
159 OutputDataType outputParameter;
166 #include "reparametrization_impl.hpp" void Forward(const arma::Mat< eT > &&input, arma::Mat< eT > &&output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
OutputDataType & Delta()
Modify the delta.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Loss()
Get the KL divergence with standard normal.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & OutputParameter()
Modify the output parameter.
size_t const & OutputSize() const
Get the output size.
OutputDataType const & OutputParameter() const
Get the output parameter.
size_t & OutputSize()
Modify the output size.
OutputDataType const & Delta() const
Get the delta.
Reparametrization()
Create the Reparametrization object.
void Backward(const arma::Mat< eT > &&input, arma::Mat< eT > &&gy, arma::Mat< eT > &&g)
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backw...