OpenANN  1.1.0
An open source library for artificial neural networks.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Namespaces | Classes | Enumerations | Functions
OpenANN Namespace Reference

Namespaces

 FANN
 
 LibSVM
 

Classes

class  AdaBoost
 Adaptive Boosting. More...
 
class  Bagging
 Bootstrap Aggregating. More...
 
class  CompressionMatrixFactory
 Creates several types of matrices for compression. More...
 
class  Compressor
 Compresses arbitrary one-dimensional data. More...
 
class  EnsembleLearner
 
class  Evaluator
 Evaluates a Learner. More...
 
class  MulticlassEvaluator
 Evaluates learners for multiclass problems. More...
 
class  IntrinsicPlasticity
 Learns the parameters of a logistic sigmoid activation function. More...
 
class  DataSet
 Data set interface. More...
 
class  DataSetView
 An index-based dataset wrapper for representing efficient dataset views on any DataSet instance. More...
 
class  DataStream
 Streams training data for online training. More...
 
class  DirectStorageDataSet
 Stores the inputs and outputs of the data set directly in two matrices. More...
 
struct  FloatingPointFormatter
 Wraps a value and its precision for logging. More...
 
class  Log
 Global logger. More...
 
class  Logger
 A local logger that can redirect messages to several targets. More...
 
class  WeightedDataSet
 Resampled dataset based on the original dataset. More...
 
class  KMeans
 K-means clustering. More...
 
class  AlphaBetaFilter
 A recurrent layer that can be used to smooth the input and estimate its derivative. More...
 
class  Compressed
 Fully connected layer with compressed weights. More...
 
class  Convolutional
 Applies a learnable filter on a 2D or 3D input. More...
 
class  Dropout
 Dropout mask. More...
 
class  Extreme
 Fully connected layer with fixed random weights. More...
 
class  FullyConnected
 Fully connected layer. More...
 
class  Input
 Input layer. More...
 
class  OutputInfo
 Provides information about the output of a layer. More...
 
class  Layer
 Interface that has to be implemented by all layers of a neural network that can be trained with backpropagation. More...
 
class  LocalResponseNormalization
 Local response normalization. More...
 
class  MaxPooling
 Performs max-pooling on 2D input feature maps. More...
 
class  SigmaPi
 Fully connected higher-order layer. More...
 
struct  DistanceConstraint
 Common constraint for encoding translation invariances into a SigmaPi layer. More...
 
struct  SlopeConstraint
 Common constraint for encoding translation and scale invariances into a SigmaPi layer. More...
 
struct  TriangleConstraint
 Common constraint for encoding translation, scale and rotation invariance into a SigmaPi layer. More...
 
class  Subsampling
 Performs average pooling on 2D input feature maps. More...
 
class  Learner
 Common base class of all learning algorithms. More...
 
class  Net
 Feedforward multilayer neural network. More...
 
class  Normalization
 Normalize data so that for each feature the mean is 0 and the standard deviation is 1. More...
 
class  OpenANNLibraryInfo
 Provides information about the OpenANN library. More...
 
class  CG
 Conjugate Gradient. More...
 
class  IPOPCMAES
 Evolution Strategies with Covariance Matrix Adaption and a restart strategy that increases the population size (IPOP-CMA-ES). More...
 
class  LBFGS
 Limited storage Broyden-Fletcher-Goldfarb-Shanno. More...
 
class  LMA
 Levenberg-Marquardt Algorithm. More...
 
class  MBSGD
 Mini-batch stochastic gradient descent. More...
 
class  Optimizable
 Represents an optimizable object. More...
 
class  Optimizer
 The common interface of all optimization algorithms. More...
 
class  StoppingCriteria
 Stopping criteria for optimization algorithms. More...
 
class  StoppingInterrupt
 A system-independent interface for checking interrupts that can signals the end of the optimization process externally. More...
 
class  PCA
 Principal component analysis. More...
 
class  RBM
 Restricted Boltzmann Machine. More...
 
class  Regularization
 Holds all information related to regularization terms in an error function. More...
 
class  ActionSpace
 Represents the action space $ A $ in a reinforcement learning problem. More...
 
class  Agent
 A (learning) agent in a reinforcement learning problem. More...
 
class  Environment
 A reinforcement learning environment. More...
 
class  RandomAgent
 Choses actions randomly. More...
 
class  StateSpace
 Represents the state space $ S $ in a reinforcement learning problem. More...
 
class  SparseAutoEncoder
 A sparse auto-encoder tries to reconstruct the inputs from a compressed representation. More...
 
class  Transformer
 Common base for all transformations. More...
 
class  OpenANNException
 This exception is thrown for all logical errors that occur in OpenANN API calls that are not time critical. More...
 
class  RandomNumberGenerator
 A utility class that simplifies the generation of random numbers. More...
 
class  ZCAWhitening
 Zero phase component analysis whitening transformation. More...
 

Enumerations

enum  ActivationFunction {
  LOGISTIC = 0, TANH = 1, TANH_SCALED = 2, RECTIFIER = 3,
  LINEAR = 4, SOFTMAX = 4
}
 
enum  ErrorFunction { NO_E_DEFINED, MSE, CE }
 Error function that will be minimized. More...
 

Functions

void activationFunction (ActivationFunction act, const Eigen::MatrixXd &a, Eigen::MatrixXd &z)
 
void activationFunctionDerivative (ActivationFunction act, const Eigen::MatrixXd &z, Eigen::MatrixXd &gd)
 
void softmax (Eigen::MatrixXd &y)
 
void logistic (const Eigen::MatrixXd &a, Eigen::MatrixXd &z)
 
void logisticDerivative (const Eigen::MatrixXd &z, Eigen::MatrixXd &gd)
 
void normaltanh (const Eigen::MatrixXd &a, Eigen::MatrixXd &z)
 
void normaltanhDerivative (const Eigen::MatrixXd &z, Eigen::MatrixXd &gd)
 
void scaledtanh (const Eigen::MatrixXd &a, Eigen::MatrixXd &z)
 
void scaledtanhDerivative (const Eigen::MatrixXd &z, Eigen::MatrixXd &gd)
 
void rectifier (const Eigen::MatrixXd &a, Eigen::MatrixXd &z)
 
void rectifierDerivative (const Eigen::MatrixXd &z, Eigen::MatrixXd &gd)
 
void linear (const Eigen::MatrixXd &a, Eigen::MatrixXd &z)
 
void linearDerivative (Eigen::MatrixXd &gd)
 
void train (Net &net, std::string algorithm, ErrorFunction errorFunction, const StoppingCriteria &stop, bool reinitialize=false, bool dropout=false)
 Train a feedforward neural network supervised. More...
 
void makeMLNN (Net &net, ActivationFunction g, ActivationFunction h, int D, int F, int H,...)
 Create a multilayer neural network. More...
 
template<typename Derived1 , typename Derived2 >
double crossEntropy (const Eigen::MatrixBase< Derived1 > &Y, const Eigen::MatrixBase< Derived2 > &T)
 Compute mean cross entropy. More...
 
template<typename Derived >
double meanSquaredError (const Eigen::MatrixBase< Derived > &YmT)
 Compute mean squared error. More...
 
double sse (Learner &learner, DataSet &dataSet)
 Sum of squared errors. More...
 
double mse (Learner &learner, DataSet &dataSet)
 Mean squared error. More...
 
double rmse (Learner &learner, DataSet &dataSet)
 Root mean squared error. More...
 
double ce (Learner &learner, DataSet &dataSet)
 Cross entropy. More...
 
double accuracy (Learner &learner, DataSet &dataSet)
 Accuracy. More...
 
double weightedAccuracy (Learner &learner, DataSet &dataSet, Eigen::VectorXd weights)
 Accuracy on weighted data set. More...
 
Eigen::MatrixXi confusionMatrix (Learner &learner, DataSet &dataSet)
 Confusion matrix. More...
 
int classificationHits (Learner &learner, DataSet &dataSet)
 Classification hits. More...
 
double crossValidation (int folds, Learner &learner, DataSet &dataSet, Optimizer &opt)
 Cross-validation. More...
 
int oneOfCDecoding (const Eigen::VectorXd &target)
 One-of-c decoding. More...
 
void split (std::vector< DataSetView > &groups, DataSet &dataset, int numberOfGroups, bool shuffling=true)
 Split the current DataSet into a specific number of DataSetView groups. More...
 
void split (std::vector< DataSetView > &groups, DataSet &dataset, double ratio=0.5, bool shuffling=true)
 Split the current DataSet into two DataSetViews where the number of containing instances are controlled by a ratio flag. More...
 
void merge (DataSetView &merging, std::vector< DataSetView > &groups)
 Merge all viewing instances from a DataSetView into another existing one. More...
 
DataSetView sample (DataSet &dataSet, double fraction, bool replacement)
 Sample random instances from the original data set. More...
 
std::ostream & operator<< (std::ostream &os, const FloatingPointFormatter &t)
 
Loggeroperator<< (Logger &logger, const FloatingPointFormatter &t)
 
template<typename T >
Loggeroperator<< (Logger &logger, const T &t)
 
void useAllCores ()
 Enable all cores for OpenMP. More...
 
void scaleData (Eigen::MatrixXd &data, double min=-1.0, double max=1.0)
 Scale all values to the interval [min, max]. More...
 
void filter (const Eigen::MatrixXd &x, Eigen::MatrixXd &y, const Eigen::MatrixXd &b, const Eigen::MatrixXd &a)
 Apply a (numerically stable) filter (FIR or IIR) on the input signal. More...
 
void downsample (const Eigen::MatrixXd &y, Eigen::MatrixXd &d, int downSamplingFactor)
 Downsample an input signal. More...
 
Eigen::MatrixXd sampleRandomPatches (const Eigen::MatrixXd &images, int channels, int rows, int cols, int samples, int patchRows, int patchCols)
 Extract random patches from a images. More...
 
template<class T >
bool equals (T a, T b, T delta)
 
template<class T >
bool isNaN (T value)
 
template<class T >
bool isInf (T value)
 

Enumeration Type Documentation

Enumerator
LOGISTIC 

Logistic sigmoid activation function.

Range: [0, 1].

$ g(a) = \frac{1}{1+\exp{{-a}}} $

TANH 

Tanh sigmoid function.

Range: [-1, 1].

$ g(a) = tanh(a) $

TANH_SCALED 

Scaled tanh sigmoid function.

This activation function does not saturate around the output -1 or +1.

Range: [-1.7159, 1.7159].

$ g(a) = 1.7159 tanh(\frac{2}{3} a) $

RECTIFIER 

Biologically inspired, non-saturating rectified linear unit (ReLU).

Range: [0, $ \infty $].

$ g(a) = max(0, a) $

[1] X. Glorot, A. Bordes, Y. Bengio: Deep Sparse Rectifier Neural Networks, International Conference on Artificial Intelligence and Statistics 15, pp. 315–323, 2011.

LINEAR 

Identity function.

Note that LINEAR and SOFTMAX are actually the same. Which function will be used actually depends on the error function: if it is MSE we will use the identity, if it is CE we will use softmax.

Range: [ $ -\infty $, $ \infty $].

$ g(a) = a $

SOFTMAX 

Softmax activation function.

Note that LINEAR and SOFTMAX are actually the same. Which function will be used actually depends on the error function: if it is MSE we will use the identity, if it is CE we will use softmax.

Range: [0, 1].

$ g(a_i) = \frac{\exp(a_i)}{\sum_j exp(a_j)} $

Error function that will be minimized.

Enumerator
NO_E_DEFINED 
MSE 

Mean squared error (regression, two classes)

CE 

Cross entropy and softmax (multiple classes)

Function Documentation

double OpenANN::accuracy ( Learner &  learner,
DataSet &  dataSet 
)

Accuracy.

The percentage of correct predictions in a classification problem.

Parameters
learnerlearned model
dataSetdataset
Returns
accuracy, within [0, 1]
void OpenANN::activationFunction ( ActivationFunction  act,
const Eigen::MatrixXd &  a,
Eigen::MatrixXd &  z 
)
void OpenANN::activationFunctionDerivative ( ActivationFunction  act,
const Eigen::MatrixXd &  z,
Eigen::MatrixXd &  gd 
)
double OpenANN::ce ( Learner &  learner,
DataSet &  dataSet 
)

Cross entropy.

This error function is usually used for classification problems.

$ E = - \sum_n \sum_f t^{(n)}_f \log y^{(n)}_f, $ where $ t^{(n)}_f $ represents the actual probability $ P(f|\bf x^{(n)}) $ and $ y^{(n)}_f $ is the prediction of the learner.

Parameters
learnerlearned model
dataSetdataset
int OpenANN::classificationHits ( Learner &  learner,
DataSet &  dataSet 
)

Classification hits.

Parameters
learnerlearned model
dataSetdataset; the targets are assumed to be encoded with 1-of-c encoding if there are 2 or more components, otherwise the output is assumed to be within [0, 1], where values of 0.5 or greater and all other values belong to different classes
Returns
number of correct predictions
Eigen::MatrixXi OpenANN::confusionMatrix ( Learner &  learner,
DataSet &  dataSet 
)

Confusion matrix.

Requires one-of-c encoded labels. The matrix row will denote the actual label and the matrix column will denote the predicted label of the learner.

Parameters
learnerlearned model
dataSetdataset
Returns
confusion matrix
template<typename Derived1 , typename Derived2 >
double OpenANN::crossEntropy ( const Eigen::MatrixBase< Derived1 > &  Y,
const Eigen::MatrixBase< Derived2 > &  T 
)

Compute mean cross entropy.

Template Parameters
Derived1matrix type
Derived2matrix type
Parameters
Yeach row contains a prediction
Teach row contains a target
Returns
average cross entropy
double OpenANN::crossValidation ( int  folds,
Learner &  learner,
DataSet &  dataSet,
Optimizer &  opt 
)

Cross-validation.

Parameters
foldsnumber of cross-validation folds
learnerlearner
dataSetdataset
optoptimization algorithm
Returns
average accuracy on validation set, within [0, 1]
void OpenANN::downsample ( const Eigen::MatrixXd &  y,
Eigen::MatrixXd &  d,
int  downSamplingFactor 
)

Downsample an input signal.

Parameters
yinput signal
ddownsampled signal
downSamplingFactordownsampling factor
template<class T >
bool OpenANN::equals ( a,
b,
delta 
)
void OpenANN::filter ( const Eigen::MatrixXd &  x,
Eigen::MatrixXd &  y,
const Eigen::MatrixXd &  b,
const Eigen::MatrixXd &  a 
)

Apply a (numerically stable) filter (FIR or IIR) on the input signal.

Parameters
xinput signal
youtput, filtered signal
bfeedforward filter coefficients
afeedback filter coefficients
template<class T >
bool OpenANN::isInf ( value)
template<class T >
bool OpenANN::isNaN ( value)
void OpenANN::linear ( const Eigen::MatrixXd &  a,
Eigen::MatrixXd &  z 
)
void OpenANN::linearDerivative ( Eigen::MatrixXd &  gd)
void OpenANN::logistic ( const Eigen::MatrixXd &  a,
Eigen::MatrixXd &  z 
)
void OpenANN::logisticDerivative ( const Eigen::MatrixXd &  z,
Eigen::MatrixXd &  gd 
)
void OpenANN::makeMLNN ( Net &  net,
ActivationFunction  g,
ActivationFunction  h,
int  D,
int  F,
int  H,
  ... 
)

Create a multilayer neural network.

Parameters
netneural network
gactivation function in hidden layers
hactivation function in output layer
Dnumber of inputs
Fnumber of outputs
Hnumber of hidden layers
...numbers of hidden units
template<typename Derived >
double OpenANN::meanSquaredError ( const Eigen::MatrixBase< Derived > &  YmT)

Compute mean squared error.

Template Parameters
Derivedmatrix type
Parameters
YmTeach row contains the difference of a prediction and a target
Returns
mean squared error
void OpenANN::merge ( DataSetView &  merging,
std::vector< DataSetView > &  groups 
)

Merge all viewing instances from a DataSetView into another existing one.

Friend declaration for direct access to indices.

Parameters
mergingthe destination DataSetView that will contain later all instances from the group
groupsnumber of DataSetView that should be merged into the destination.
double OpenANN::mse ( Learner &  learner,
DataSet &  dataSet 
)

Mean squared error.

This error function is usually used for regression problems.

$ E = \frac{1}{N} \sum_n \sum_f (y^{(n)}_f - t^{(n)}_f)^2, $ where $ y^{(n)}_f $ is the predicted output, $ t^{(n)}_f $ the desired output and $ N $ is size of the dataset.

Parameters
learnerlearned model
dataSetdataset
Returns
MSE
void OpenANN::normaltanh ( const Eigen::MatrixXd &  a,
Eigen::MatrixXd &  z 
)
void OpenANN::normaltanhDerivative ( const Eigen::MatrixXd &  z,
Eigen::MatrixXd &  gd 
)
int OpenANN::oneOfCDecoding ( const Eigen::VectorXd &  target)

One-of-c decoding.

If the length of the vector is 1 it is interpreted as probability for the class 1.

Parameters
targetvector that represents a 1-of-c encoded class label
Returns
index of entry with the highest value or class index
std::ostream& OpenANN::operator<< ( std::ostream &  os,
const FloatingPointFormatter &  t 
)
Logger& OpenANN::operator<< ( Logger &  logger,
const FloatingPointFormatter &  t 
)
template<typename T >
Logger& OpenANN::operator<< ( Logger &  logger,
const T &  t 
)
void OpenANN::rectifier ( const Eigen::MatrixXd &  a,
Eigen::MatrixXd &  z 
)
void OpenANN::rectifierDerivative ( const Eigen::MatrixXd &  z,
Eigen::MatrixXd &  gd 
)
double OpenANN::rmse ( Learner &  learner,
DataSet &  dataSet 
)

Root mean squared error.

This error function is usually used for regression problems.

$ E = \sqrt(\frac{1}{N} \sum_n \sum_f (y^{(n)}_f - t^{(n)}_f)^2), $ where $ y^{(n)}_f $ is the predicted output, $ t^{(n)}_f $ the desired output and $ N $ is size of the dataset.

Parameters
learnerlearned model
dataSetdataset
Returns
RMSE
DataSetView OpenANN::sample ( DataSet &  dataSet,
double  fraction,
bool  replacement 
)

Sample random instances from the original data set.

Parameters
dataSetoriginal data set
fractionfraction of the original data set's size, must be within (0, 1)
replacementdraw with or without replacement
Returns
sample from the original data set
Eigen::MatrixXd OpenANN::sampleRandomPatches ( const Eigen::MatrixXd &  images,
int  channels,
int  rows,
int  cols,
int  samples,
int  patchRows,
int  patchCols 
)

Extract random patches from a images.

Parameters
imageseach row contains an original image
channelsnumber of color channels, e.g. 3 for RGB, 1 for grayscale
rowsheight of the images
colswidth of the images
samplesnumber of sampled patches for each image
patchRowsheight of image patches
patchColswidth of image patches
Returns
sampled patches, each row represents a patch
void OpenANN::scaleData ( Eigen::MatrixXd &  data,
double  min = -1.0,
double  max = 1.0 
)

Scale all values to the interval [min, max].

Parameters
datamatrix that contains e. g. network inputs or outputs
minminimum value of the output
maxmaximum value of the output
void OpenANN::scaledtanh ( const Eigen::MatrixXd &  a,
Eigen::MatrixXd &  z 
)
void OpenANN::scaledtanhDerivative ( const Eigen::MatrixXd &  z,
Eigen::MatrixXd &  gd 
)
void OpenANN::softmax ( Eigen::MatrixXd &  y)
void OpenANN::split ( std::vector< DataSetView > &  groups,
DataSet &  dataset,
int  numberOfGroups,
bool  shuffling = true 
)

Split the current DataSet into a specific number of DataSetView groups.

Parameters
groupsstd::vector reference that will be filled with new dataset views.
datasetreference for internal instances of each dataset view
numberOfGroupsthe number of DataSetView generated by this call
shufflingif so, the split is called on a shuffled version of the reference dataset
void OpenANN::split ( std::vector< DataSetView > &  groups,
DataSet &  dataset,
double  ratio = 0.5,
bool  shuffling = true 
)

Split the current DataSet into two DataSetViews where the number of containing instances are controlled by a ratio flag.

Parameters
groupsstd::vector reference that will be filled with two dataset views.
datasetreference for internal instances of each dataset view
ratiosets the ratio of the sample count between the two sets
  • groups.front().size() == ratio * dataset.samples()
  • groups.back().size() == (1.0 - ratio) * dataset.samples()
shufflingif so, the split is called on a shuffled version of the reference dataset
double OpenANN::sse ( Learner &  learner,
DataSet &  dataSet 
)

Sum of squared errors.

This error function is usually used for regression problems.

$ E = \sum_n \sum_f (y^{(n)}_f - t^{(n)}_f)^2, $ where $ y^{(n)}_f $ is the predicted output and $ t^{(n)}_f $ the desired output.

Parameters
learnerlearned model
dataSetdataset
Returns
SSE
void OpenANN::train ( Net &  net,
std::string  algorithm,
ErrorFunction  errorFunction,
const StoppingCriteria &  stop,
bool  reinitialize = false,
bool  dropout = false 
)

Train a feedforward neural network supervised.

Parameters
netneural network
algorithma registered algorithm, e.g. "MBSGD", "LMA", "CG", "LBFGS" or "CMAES"
errorFunctionerror function to optimize
stopstopping criteria
reinitializeshould the weights be initialized before optimization?
dropoutuse dropout for regularization
void OpenANN::useAllCores ( )

Enable all cores for OpenMP.

The number of available cores must be specified during the build of OpenANN. It can be set with the CMake variable PARALLEL_CORES. Note that you should use only the maximum number of available physical cores. Virtual cores will usually slow matrix operations down.

double OpenANN::weightedAccuracy ( Learner &  learner,
DataSet &  dataSet,
Eigen::VectorXd  weights 
)

Accuracy on weighted data set.

Parameters
learnerlearned model
dataSetdataset
weightsweights for each instance, must sum up to one
Returns
accuracy on weighted data set, within [0, 1]