openGPMP
Open Source Mathematics Package
Functions
encoders.cpp File Reference
#include <iostream>
#include <openGPMP/ml.hpp>
#include <vector>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( void  )

Definition at line 4 of file encoders.cpp.

4  {
5  srand(time(0));
6 
7  // Vanilla AutoEncoder
8  gpmp::ml::AutoEncoder ae(3, 2, 3, 0.1);
9 
10  std::cout << "Vanilla AutoEncoder Training:\n";
11  std::vector<std::vector<double>> ae_training_data = {{1, 0, 0},
12  {0, 1, 0},
13  {0, 0, 1}};
14  ae.train(ae_training_data, 1000);
15  ae.display();
16 
17  std::cout << "\nTesting Vanilla AutoEncoder:\n";
18  std::vector<double> test_input = {1, 1, 0};
19  std::vector<double> output = ae.forward(test_input);
20  std::cout << "Autoencoder Output:\n";
21  for (double val : output) {
22  std::cout << val << " ";
23  }
24 
25  // Sparse AutoEncoder
26  gpmp::ml::SparseAutoEncoder sparse_ae(3, 2, 3, 0.1, 0.01, 0.2);
27 
28  std::cout << "\n\nSparse AutoEncoder Training:\n";
29  std::vector<std::vector<double>> ae_training_data_sparse = {{1, 0, 0},
30  {0, 1, 0},
31  {0, 0, 1}};
32  sparse_ae.train(ae_training_data_sparse, 1000);
33  sparse_ae.display();
34 
35  // Denoising AutoEncoder
36  gpmp::ml::DenoisingAutoEncoder denoise_ae(3, 2, 3, 0.1, 0.2);
37 
38  std::cout << "\nDenoising AutoEncoder Training:\n";
39  denoise_ae.train(ae_training_data, 1000);
40  denoise_ae.display();
41 
42  // Contractive AutoEncoder
43  gpmp::ml::ContractiveAutoEncoder contractive_ae(3, 2, 3, 0.1, 0.01);
44 
45  std::cout << "\nContractive AutoEncoder Training:\n";
46  contractive_ae.train(ae_training_data, 1000);
47  contractive_ae.display();
48 
49  // Recurrent AutoEncoder
50  gpmp::ml::RecurrentAutoEncoder recurrent_ae(3, 2, 3, 0.1);
51 
52  std::cout << "\nRecurrent AutoEncoder Training:\n";
53  std::vector<std::vector<double>> recurrent_ae_training_data = {{1, 0, 0},
54  {0, 1, 0},
55  {0, 0, 1}};
56  recurrent_ae.train(recurrent_ae_training_data, 1000);
57  recurrent_ae.display();
58 
59  return 0;
60 }
A simple implementation of a vanilla autoencoder.
Definition: encoder.hpp:59
ContractiveAutoEncoder class, a derived class from AutoEncoder.
Definition: encoder.hpp:276
DenoisingAutoEncoder class, a derived class from AutoEncoder.
Definition: encoder.hpp:237
RecurrentAutoEncoder class, a derived class from AutoEncoder.
Definition: encoder.hpp:475
SparseAutoEncoder class, a derived class from AutoEncoder.
Definition: encoder.hpp:193

References gpmp::ml::AutoEncoder::display(), gpmp::ml::AutoEncoder::forward(), gpmp::ml::AutoEncoder::train(), gpmp::ml::SparseAutoEncoder::train(), gpmp::ml::DenoisingAutoEncoder::train(), gpmp::ml::ContractiveAutoEncoder::train(), and gpmp::ml::RecurrentAutoEncoder::train().