MLPACK  1.0.11
sparse_autoencoder.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_METHODS_SPARSE_AUTOENCODER_SPARSE_AUTOENCODER_HPP
23 #define __MLPACK_METHODS_SPARSE_AUTOENCODER_SPARSE_AUTOENCODER_HPP
24 
25 #include <mlpack/core.hpp>
27 
29 
30 namespace mlpack {
31 namespace nn {
32 
75 template<
76  template<typename> class OptimizerType = mlpack::optimization::L_BFGS
77 >
79 {
80  public:
94  SparseAutoencoder(const arma::mat& data,
95  const size_t visibleSize,
96  const size_t hiddenSize,
97  const double lambda = 0.0001,
98  const double beta = 3,
99  const double rho = 0.01);
100 
110  SparseAutoencoder(OptimizerType<SparseAutoencoderFunction>& optimizer);
111 
120  void GetNewFeatures(arma::mat& data, arma::mat& features);
121 
128  void Sigmoid(const arma::mat& x, arma::mat& output) const
129  {
130  output = (1.0 / (1 + arma::exp(-x)));
131  }
132 
134  void VisibleSize(const size_t visible)
135  {
136  this->visibleSize = visible;
137  }
138 
140  size_t VisibleSize() const
141  {
142  return visibleSize;
143  }
144 
146  void HiddenSize(const size_t hidden)
147  {
148  this->hiddenSize = hidden;
149  }
150 
152  size_t HiddenSize() const
153  {
154  return hiddenSize;
155  }
156 
158  void Lambda(const double l)
159  {
160  this->lambda = l;
161  }
162 
164  double Lambda() const
165  {
166  return lambda;
167  }
168 
170  void Beta(const double b)
171  {
172  this->beta = b;
173  }
174 
176  double Beta() const
177  {
178  return beta;
179  }
180 
182  void Rho(const double r)
183  {
184  this->rho = r;
185  }
186 
188  double Rho() const
189  {
190  return rho;
191  }
192 
193  private:
195  arma::mat parameters;
197  size_t visibleSize;
199  size_t hiddenSize;
201  double lambda;
203  double beta;
205  double rho;
206 };
207 
208 }; // namespace nn
209 }; // namespace mlpack
210 
211 // Include implementation.
212 #include "sparse_autoencoder_impl.hpp"
213 
214 #endif
double Lambda() const
Gets the L2-regularization parameter.
void GetNewFeatures(arma::mat &data, arma::mat &features)
Transforms the provided data into the representation learned by the sparse autoencoder.
void Sigmoid(const arma::mat &x, arma::mat &output) const
Returns the elementwise sigmoid of the passed matrix, where the sigmoid function of a real number 'x'...
void VisibleSize(const size_t visible)
Sets size of the visible layer.
double Rho() const
Gets the sparsity parameter.
arma::mat parameters
Parameters after optimization.
void Rho(const double r)
Sets the sparsity parameter.
A sparse autoencoder is a neural network whose aim to learn compressed representations of the data...
double lambda
L2-regularization parameter.
void HiddenSize(const size_t hidden)
Sets size of the hidden layer.
size_t visibleSize
Size of the visible layer.
void Lambda(const double l)
Sets the L2-regularization parameter.
size_t hiddenSize
Size of the hidden layer.
size_t VisibleSize() const
Gets size of the visible layer.
double rho
Sparsity parameter.
double Beta() const
Gets the KL divergence parameter.
double beta
KL divergence parameter.
void Beta(const double b)
Sets the KL divergence parameter.
size_t HiddenSize() const
Gets the size of the hidden layer.
SparseAutoencoder(const arma::mat &data, const size_t visibleSize, const size_t hiddenSize, const double lambda=0.0001, const double beta=3, const double rho=0.01)
Construct the sparse autoencoder model with the given training data.
The generic L-BFGS optimizer, which uses a back-tracking line search algorithm to minimize a function...
Definition: lbfgs.hpp:44