openGPMP
Open Source Mathematics Package
|
VariationalAutoEncoder class, a derived class from AutoEncoder. More...
#include <encoder.hpp>
Public Member Functions | |
double | sample_dist () |
Samples from a standard normal distribution. More... | |
double | reparameterize (double mean, double log_variance) |
Reparameterization trick for variational autoencoders. More... | |
std::vector< double > | encoder (const std::vector< double > &input) |
Performs the forward pass for the encoder and returns hidden activations. More... | |
std::vector< double > | decoder (const std::vector< double > &hidden_sampled) |
Performs the forward pass for the decoder and returns output activations. More... | |
void | gradient_descent (const std::vector< double > &input, const std::vector< double > &output, const std::vector< double > &hidden_sampled) |
Performs the backward pass (gradient descent) updating weights. More... | |
VariationalAutoEncoder (int input_size, int hidden_size, int output_size, double learning_rate) | |
Constructor for the VariationalAutoEncoder class. More... | |
virtual void | train (const std::vector< std::vector< double >> &training_data, int epochs) override |
Trains the Variational autoencoder on the given training data. More... | |
Public Member Functions inherited from gpmp::ml::AutoEncoder | |
AutoEncoder (int input_size, int hidden_size, int output_size, double learning_rate) | |
Constructor for the AutoEncoder class. More... | |
std::vector< double > | sigmoid (const std::vector< double > &x) |
Sigmoid activation function. More... | |
std::vector< double > | forward (const std::vector< double > &input) |
Forward pass through the autoencoder. More... | |
void | lrate_set (double initial_rate) |
Set the initial learning rate. More... | |
virtual void | lrate_update (int epoch) |
Update the learning rate based on a schedule. More... | |
void | display () |
Print the weights of the autoencoder. More... | |
virtual void | save (const std::string &filename) const |
Save the model weights to a file. More... | |
virtual void | load (const std::string &filename) |
Load model weights from a file. More... | |
Public Attributes | |
std::vector< double > | hidden_mean |
keeps track of hidden means More... | |
std::vector< double > | hidden_log_variance |
keeps track of hidden log variance More... | |
Public Attributes inherited from gpmp::ml::AutoEncoder | |
int | input_size |
Size of the input layer. More... | |
int | hidden_size |
Size of the hidden layer. More... | |
int | output_size |
Size of the output layer. More... | |
double | learning_rate |
Learning rate for training the autoencoder. More... | |
std::vector< std::vector< double > > | weights_input_hidden |
Weights from the input layer to the hidden layer. More... | |
std::vector< std::vector< double > > | weights_hidden_output |
Weights from the hidden layer to the output layer. More... | |
VariationalAutoEncoder class, a derived class from AutoEncoder.
Definition at line 390 of file encoder.hpp.
gpmp::ml::VariationalAutoEncoder::VariationalAutoEncoder | ( | int | input_size, |
int | hidden_size, | ||
int | output_size, | ||
double | learning_rate | ||
) |
Constructor for the VariationalAutoEncoder class.
input_size | The size of the input layer |
hidden_size | The size of the hidden layer |
output_size | The size of the output layer |
learning_rate | The learning rate for training |
Definition at line 470 of file encoder.cpp.
std::vector< double > gpmp::ml::VariationalAutoEncoder::decoder | ( | const std::vector< double > & | hidden_sampled | ) |
Performs the forward pass for the decoder and returns output activations.
hidden_sampled | The sampled hidden values. |
Definition at line 504 of file encoder.cpp.
std::vector< double > gpmp::ml::VariationalAutoEncoder::encoder | ( | const std::vector< double > & | input | ) |
Performs the forward pass for the encoder and returns hidden activations.
input | The input data. |
Definition at line 490 of file encoder.cpp.
void gpmp::ml::VariationalAutoEncoder::gradient_descent | ( | const std::vector< double > & | input, |
const std::vector< double > & | output, | ||
const std::vector< double > & | hidden_sampled | ||
) |
Performs the backward pass (gradient descent) updating weights.
input | The input data. |
output | The output activations. |
hidden_sampled | The sampled hidden values. |
Definition at line 519 of file encoder.cpp.
double gpmp::ml::VariationalAutoEncoder::reparameterize | ( | double | mean, |
double | log_variance | ||
) |
Reparameterization trick for variational autoencoders.
mean | The mean of the distribution |
log_variance | The log variance of the distribution |
Definition at line 483 of file encoder.cpp.
double gpmp::ml::VariationalAutoEncoder::sample_dist | ( | ) |
Samples from a standard normal distribution.
Definition at line 477 of file encoder.cpp.
|
overridevirtual |
Trains the Variational autoencoder on the given training data.
Overrides the train method in the base class with Variational autoencoder specifics
training_data | The training data |
epochs | The number of training epochs |
Reimplemented from gpmp::ml::AutoEncoder.
Definition at line 552 of file encoder.cpp.
std::vector<double> gpmp::ml::VariationalAutoEncoder::hidden_log_variance |
keeps track of hidden log variance
Definition at line 399 of file encoder.hpp.
std::vector<double> gpmp::ml::VariationalAutoEncoder::hidden_mean |
keeps track of hidden means
Definition at line 395 of file encoder.hpp.