13 #ifndef MLPACK_METHODS_ANN_LAYER_REPARAMETRIZATION_HPP 14 #define MLPACK_METHODS_ANN_LAYER_REPARAMETRIZATION_HPP 54 typename InputType = arma::mat,
55 typename OutputType = arma::mat
70 const bool includeKl =
true,
71 const double beta = 1);
111 void Forward(
const InputType& input, OutputType& output);
122 void Backward(
const InputType& input,
123 const OutputType& gy,
140 double Beta()
const {
return beta; }
142 double&
Beta() {
return beta; }
146 const size_t inputElem = std::accumulate(this->
inputDimensions.begin(),
148 if (inputElem % 2 != 0)
150 std::ostringstream oss;
151 oss <<
"Reparametrization layer requires that the total number of input " 152 <<
"elements is divisible by 2! (Received input with " << inputElem
153 <<
" total elements.)";
154 throw std::invalid_argument(oss.str());
160 this->outputDimensions[0] = inputElem / 2;
166 template<
typename Archive>
167 void serialize(Archive& ar,
const uint32_t );
180 OutputType gaussianSample;
187 OutputType preStdDev;
200 #include "reparametrization_impl.hpp" bool IncludeKL() const
Get the value of the includeKl parameter.
void Backward(const InputType &input, const OutputType &gy, OutputType &g)
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backw...
std::vector< size_t > inputDimensions
Logical input dimensions of each point.
void ComputeOutputDimensions()
Compute the output dimensions.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Linear algebra utility functions, generally performed on matrices or vectors.
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
The core includes that mlpack expects; standard C++ includes and Armadillo.
ReparametrizationType * Clone() const
Clone the ReparametrizationType object.
std::vector< size_t > outputDimensions
Logical output dimensions of each point.
double Beta() const
Get the value of the beta hyperparameter.
bool Stochastic() const
Get the value of the stochastic parameter.
virtual ~ReparametrizationType()
bool & IncludeKL()
Modify the value of the includeKl parameter.
bool & Stochastic()
Modify the value of the stochastic parameter.
ReparametrizationType(const bool stochastic=true, const bool includeKl=true, const double beta=1)
Create the Reparametrization layer object.
A layer is an abstract class implementing common neural networks operations, such as convolution...
double Loss()
Get the KL divergence with standard normal.
ReparametrizationType & operator=(const ReparametrizationType &layer)
Copy assignment operator.
Implementation of the Reparametrization layer class.
double & Beta()
Modify the value of the beta hyperparameter.
ReparametrizationType< arma::mat, arma::mat > Reparametrization