MLPACK  1.0.11
sparse_autoencoder_function.hpp
Go to the documentation of this file.
1 
23 #ifndef __MLPACK_METHODS_SPARSE_AUTOENCODER_SPARSE_AUTOENCODER_FUNCTION_HPP
24 #define __MLPACK_METHODS_SPARSE_AUTOENCODER_SPARSE_AUTOENCODER_FUNCTION_HPP
25 
26 #include <mlpack/core.hpp>
27 
28 namespace mlpack {
29 namespace nn {
30 
37 {
38  public:
50  SparseAutoencoderFunction(const arma::mat& data,
51  const size_t visibleSize,
52  const size_t hiddenSize,
53  const double lambda = 0.0001,
54  const double beta = 3,
55  const double rho = 0.01);
56 
58  const arma::mat InitializeWeights();
59 
70  double Evaluate(const arma::mat& parameters) const;
71 
81  void Gradient(const arma::mat& parameters, arma::mat& gradient) const;
82 
89  void Sigmoid(const arma::mat& x, arma::mat& output) const
90  {
91  output = (1.0 / (1 + arma::exp(-x)));
92  }
93 
95  const arma::mat& GetInitialPoint() const { return initialPoint; }
96 
98  void VisibleSize(const size_t visible)
99  {
100  this->visibleSize = visible;
101  }
102 
104  size_t VisibleSize() const
105  {
106  return visibleSize;
107  }
108 
110  void HiddenSize(const size_t hidden)
111  {
112  this->hiddenSize = hidden;
113  }
114 
116  size_t HiddenSize() const
117  {
118  return hiddenSize;
119  }
120 
122  void Lambda(const double l)
123  {
124  this->lambda = l;
125  }
126 
128  double Lambda() const
129  {
130  return lambda;
131  }
132 
134  void Beta(const double b)
135  {
136  this->beta = b;
137  }
138 
140  double Beta() const
141  {
142  return beta;
143  }
144 
146  void Rho(const double r)
147  {
148  this->rho = r;
149  }
150 
152  double Rho() const
153  {
154  return rho;
155  }
156 
157  private:
159  const arma::mat& data;
161  arma::mat initialPoint;
163  size_t visibleSize;
165  size_t hiddenSize;
167  double lambda;
169  double beta;
171  double rho;
172 };
173 
174 }; // namespace nn
175 }; // namespace mlpack
176 
177 #endif
size_t VisibleSize() const
Gets size of the visible layer.
double lambda
L2-regularization parameter.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:31
This is a class for the sparse autoencoder objective function.
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'...
SparseAutoencoderFunction(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 objective function with the given parameters.
size_t HiddenSize() const
Gets the size of the hidden layer.
void Rho(const double r)
Sets the sparsity parameter.
const arma::mat & GetInitialPoint() const
Return the initial point for the optimization.
const arma::mat & data
The matrix of data points.
double Beta() const
Gets the KL divergence parameter.
size_t visibleSize
Size of the visible layer.
double Lambda() const
Gets the L2-regularization parameter.
arma::mat initialPoint
Intial parameter vector.
void HiddenSize(const size_t hidden)
Sets size of the hidden layer.
const arma::mat InitializeWeights()
Initializes the parameters of the model to suitable values.
void Beta(const double b)
Sets the KL divergence parameter.
double Evaluate(const arma::mat &parameters) const
Evaluates the objective function of the sparse autoencoder model using the given parameters.
void VisibleSize(const size_t visible)
Sets size of the visible layer.
double Rho() const
Gets the sparsity parameter.
void Lambda(const double l)
Sets the L2-regularization parameter.
void Gradient(const arma::mat &parameters, arma::mat &gradient) const
Evaluates the gradient values of the objective function given the current set of parameters.