mlpack  master
Public Member Functions | Private Attributes | List of all members
mlpack::nn::SparseAutoencoderFunction Class Reference

This is a class for the sparse autoencoder objective function. More...

Public Member Functions

 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. More...
 
void Beta (const double b)
 Sets the KL divergence parameter. More...
 
double Beta () const
 Gets the KL divergence parameter. More...
 
double Evaluate (const arma::mat &parameters) const
 Evaluates the objective function of the sparse autoencoder model using the given parameters. More...
 
const arma::mat & GetInitialPoint () const
 Return the initial point for the optimization. More...
 
void Gradient (const arma::mat &parameters, arma::mat &gradient) const
 Evaluates the gradient values of the objective function given the current set of parameters. More...
 
void HiddenSize (const size_t hidden)
 Sets size of the hidden layer. More...
 
size_t HiddenSize () const
 Gets the size of the hidden layer. More...
 
const arma::mat InitializeWeights ()
 Initializes the parameters of the model to suitable values. More...
 
void Lambda (const double l)
 Sets the L2-regularization parameter. More...
 
double Lambda () const
 Gets the L2-regularization parameter. More...
 
void Rho (const double r)
 Sets the sparsity parameter. More...
 
double Rho () const
 Gets the sparsity parameter. More...
 
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' is [1 / (1 + exp(-x))]. More...
 
void VisibleSize (const size_t visible)
 Sets size of the visible layer. More...
 
size_t VisibleSize () const
 Gets size of the visible layer. More...
 

Private Attributes

double beta
 KL divergence parameter. More...
 
const arma::mat & data
 The matrix of data points. More...
 
size_t hiddenSize
 Size of the hidden layer. More...
 
arma::mat initialPoint
 Initial parameter vector. More...
 
double lambda
 L2-regularization parameter. More...
 
double rho
 Sparsity parameter. More...
 
size_t visibleSize
 Size of the visible layer. More...
 

Detailed Description

This is a class for the sparse autoencoder objective function.

It can be used to create learning models like self-taught learning, stacked autoencoders, conditional random fields (CRFs), and so forth.

Definition at line 26 of file sparse_autoencoder_function.hpp.

Constructor & Destructor Documentation

mlpack::nn::SparseAutoencoderFunction::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.

Parameters
dataThe data matrix.
visibleSizeSize of input vector expected at the visible layer.
hiddenSizeSize of input vector expected at the hidden layer.
lambdaL2-regularization parameter.
betaKL divergence parameter.
rhoSparsity parameter.

Member Function Documentation

void mlpack::nn::SparseAutoencoderFunction::Beta ( const double  b)
inline

Sets the KL divergence parameter.

Definition at line 124 of file sparse_autoencoder_function.hpp.

References beta.

double mlpack::nn::SparseAutoencoderFunction::Beta ( ) const
inline

Gets the KL divergence parameter.

Definition at line 130 of file sparse_autoencoder_function.hpp.

References beta.

double mlpack::nn::SparseAutoencoderFunction::Evaluate ( const arma::mat &  parameters) const

Evaluates the objective function of the sparse autoencoder model using the given parameters.

The cost function has terms for the reconstruction error, regularization cost and the sparsity cost. The objective function takes a low value when the model is able to reconstruct the data well using weights which are low in value and when the average activations of neurons in the hidden layers agrees well with the sparsity parameter 'rho'.

Parameters
parametersCurrent values of the model parameters.
const arma::mat& mlpack::nn::SparseAutoencoderFunction::GetInitialPoint ( ) const
inline

Return the initial point for the optimization.

Definition at line 85 of file sparse_autoencoder_function.hpp.

References initialPoint.

void mlpack::nn::SparseAutoencoderFunction::Gradient ( const arma::mat &  parameters,
arma::mat &  gradient 
) const

Evaluates the gradient values of the objective function given the current set of parameters.

The function performs a feedforward pass and computes the error in reconstructing the data points. It then uses the backpropagation algorithm to compute the gradient values.

Parameters
parametersCurrent values of the model parameters.
gradientMatrix where gradient values will be stored.
void mlpack::nn::SparseAutoencoderFunction::HiddenSize ( const size_t  hidden)
inline

Sets size of the hidden layer.

Definition at line 100 of file sparse_autoencoder_function.hpp.

size_t mlpack::nn::SparseAutoencoderFunction::HiddenSize ( ) const
inline

Gets the size of the hidden layer.

Definition at line 106 of file sparse_autoencoder_function.hpp.

References hiddenSize.

const arma::mat mlpack::nn::SparseAutoencoderFunction::InitializeWeights ( )

Initializes the parameters of the model to suitable values.

void mlpack::nn::SparseAutoencoderFunction::Lambda ( const double  l)
inline

Sets the L2-regularization parameter.

Definition at line 112 of file sparse_autoencoder_function.hpp.

References lambda.

double mlpack::nn::SparseAutoencoderFunction::Lambda ( ) const
inline

Gets the L2-regularization parameter.

Definition at line 118 of file sparse_autoencoder_function.hpp.

References lambda.

void mlpack::nn::SparseAutoencoderFunction::Rho ( const double  r)
inline

Sets the sparsity parameter.

Definition at line 136 of file sparse_autoencoder_function.hpp.

References rho.

double mlpack::nn::SparseAutoencoderFunction::Rho ( ) const
inline

Gets the sparsity parameter.

Definition at line 142 of file sparse_autoencoder_function.hpp.

References rho.

void mlpack::nn::SparseAutoencoderFunction::Sigmoid ( const arma::mat &  x,
arma::mat &  output 
) const
inline

Returns the elementwise sigmoid of the passed matrix, where the sigmoid function of a real number 'x' is [1 / (1 + exp(-x))].

Parameters
xMatrix of real values for which we require the sigmoid activation.

Definition at line 79 of file sparse_autoencoder_function.hpp.

void mlpack::nn::SparseAutoencoderFunction::VisibleSize ( const size_t  visible)
inline

Sets size of the visible layer.

Definition at line 88 of file sparse_autoencoder_function.hpp.

size_t mlpack::nn::SparseAutoencoderFunction::VisibleSize ( ) const
inline

Gets size of the visible layer.

Definition at line 94 of file sparse_autoencoder_function.hpp.

References visibleSize.

Member Data Documentation

double mlpack::nn::SparseAutoencoderFunction::beta
private

KL divergence parameter.

Definition at line 159 of file sparse_autoencoder_function.hpp.

Referenced by Beta().

const arma::mat& mlpack::nn::SparseAutoencoderFunction::data
private

The matrix of data points.

Definition at line 149 of file sparse_autoencoder_function.hpp.

size_t mlpack::nn::SparseAutoencoderFunction::hiddenSize
private

Size of the hidden layer.

Definition at line 155 of file sparse_autoencoder_function.hpp.

Referenced by HiddenSize().

arma::mat mlpack::nn::SparseAutoencoderFunction::initialPoint
private

Initial parameter vector.

Definition at line 151 of file sparse_autoencoder_function.hpp.

Referenced by GetInitialPoint().

double mlpack::nn::SparseAutoencoderFunction::lambda
private

L2-regularization parameter.

Definition at line 157 of file sparse_autoencoder_function.hpp.

Referenced by Lambda().

double mlpack::nn::SparseAutoencoderFunction::rho
private

Sparsity parameter.

Definition at line 161 of file sparse_autoencoder_function.hpp.

Referenced by Rho().

size_t mlpack::nn::SparseAutoencoderFunction::visibleSize
private

Size of the visible layer.

Definition at line 153 of file sparse_autoencoder_function.hpp.

Referenced by VisibleSize().


The documentation for this class was generated from the following file: