mlpack  2.2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sparse_autoencoder.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_SPARSE_AUTOENCODER_SPARSE_AUTOENCODER_HPP
13 #define MLPACK_METHODS_SPARSE_AUTOENCODER_SPARSE_AUTOENCODER_HPP
14 
15 #include <mlpack/prereqs.hpp>
17 
19 
20 namespace mlpack {
21 namespace nn {
22 
65 template<
66  template<typename> class OptimizerType = mlpack::optimization::L_BFGS
67 >
69 {
70  public:
84  SparseAutoencoder(const arma::mat& data,
85  const size_t visibleSize,
86  const size_t hiddenSize,
87  const double lambda = 0.0001,
88  const double beta = 3,
89  const double rho = 0.01);
90 
100  SparseAutoencoder(OptimizerType<SparseAutoencoderFunction>& optimizer);
101 
110  void GetNewFeatures(arma::mat& data, arma::mat& features);
111 
118  void Sigmoid(const arma::mat& x, arma::mat& output) const
119  {
120  output = (1.0 / (1 + arma::exp(-x)));
121  }
122 
124  void VisibleSize(const size_t visible)
125  {
126  this->visibleSize = visible;
127  }
128 
130  size_t VisibleSize() const
131  {
132  return visibleSize;
133  }
134 
136  void HiddenSize(const size_t hidden)
137  {
138  this->hiddenSize = hidden;
139  }
140 
142  size_t HiddenSize() const
143  {
144  return hiddenSize;
145  }
146 
148  void Lambda(const double l)
149  {
150  this->lambda = l;
151  }
152 
154  double Lambda() const
155  {
156  return lambda;
157  }
158 
160  void Beta(const double b)
161  {
162  this->beta = b;
163  }
164 
166  double Beta() const
167  {
168  return beta;
169  }
170 
172  void Rho(const double r)
173  {
174  this->rho = r;
175  }
176 
178  double Rho() const
179  {
180  return rho;
181  }
182 
183  private:
185  arma::mat parameters;
187  size_t visibleSize;
189  size_t hiddenSize;
191  double lambda;
193  double beta;
195  double rho;
196 };
197 
198 } // namespace nn
199 } // namespace mlpack
200 
201 // Include implementation.
202 #include "sparse_autoencoder_impl.hpp"
203 
204 #endif
size_t HiddenSize() const
Gets the size of the hidden layer.
double Beta() const
Gets the KL divergence parameter.
void GetNewFeatures(arma::mat &data, arma::mat &features)
Transforms the provided data into the representation learned by the sparse autoencoder.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Rho(const double r)
Sets the sparsity parameter.
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.
double Rho() const
Gets the sparsity parameter.
A sparse autoencoder is a neural network whose aim to learn compressed representations of the data...
void Lambda(const double l)
Sets the L2-regularization parameter.
void Beta(const double b)
Sets the KL divergence parameter.
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 &#39;x&#39;...
size_t VisibleSize() const
Gets size of the visible layer.
The generic L-BFGS optimizer, which uses a back-tracking line search algorithm to minimize a function...
Definition: lbfgs.hpp:34
void HiddenSize(const size_t hidden)
Sets size of the hidden layer.
void VisibleSize(const size_t visible)
Sets size of the visible layer.
double Lambda() const
Gets the L2-regularization parameter.