org.apache.mahout.classifier.mlp
Class MultilayerPerceptron

java.lang.Object
  extended by org.apache.mahout.classifier.mlp.NeuralNetwork
      extended by org.apache.mahout.classifier.mlp.MultilayerPerceptron
All Implemented Interfaces:
Closeable, OnlineLearner

public class MultilayerPerceptron
extends NeuralNetwork
implements OnlineLearner

A Multilayer Perceptron (MLP) is a kind of feed-forward artificial neural network, which is a mathematical model inspired by the biological neural network. The Multilayer Perceptron can be used for various machine learning tasks such as classification and regression. A detailed introduction about MLP can be found at http://ufldl.stanford.edu/wiki/index.php/Neural_Networks. For this particular implementation, the users can freely control the topology of the MLP, including: 1. The size of the input layer; 2. The number of hidden layers; 3. The size of each hidden layer; 4. The size of the output layer. 5. The cost function. 6. The squashing function. The model is trained in an online learning approach, where the weights of neurons in the MLP is updated incremented using backPropagation algorithm proposed by (Rumelhart, D. E., Hinton, G. E., and Williams, R. J. (1986) Learning representations by back-propagating errors. Nature, 323, 533--536.)


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.mahout.classifier.mlp.NeuralNetwork
NeuralNetwork.TrainingMethod
 
Field Summary
 
Fields inherited from class org.apache.mahout.classifier.mlp.NeuralNetwork
costFunctionName, finalLayerIdx, layerSizeList, learningRate, modelPath, modelType, momentumWeight, prevWeightUpdatesList, regularizationWeight, squashingFunctionList, trainingMethod, weightMatrixList
 
Constructor Summary
MultilayerPerceptron()
          The default constructor.
MultilayerPerceptron(String modelPath)
          Initialize the MLP by specifying the location of the model.
 
Method Summary
 void close()
          Prepares the classifier for classification and deallocates any temporary data structures.
 void train(int actual, Vector instance)
          Updates the model using a particular target variable value and a feature vector.
 void train(long trackingKey, int actual, Vector instance)
          Updates the model using a particular target variable value and a feature vector.
 void train(long trackingKey, String groupKey, int actual, Vector instance)
          Updates the model using a particular target variable value and a feature vector.
 
Methods inherited from class org.apache.mahout.classifier.mlp.NeuralNetwork
addLayer, forward, getLayerSize, getLayerSizeList, getLearningRate, getModelPath, getModelType, getMomentumWeight, getOutput, getOutputInternal, getRegularizationWeight, getTrainingMethod, getWeightMatrices, getWeightsByLayer, readFields, readFromModel, setCostFunction, setLearningRate, setModelPath, setMomentumWeight, setRegularizationWeight, setTrainingMethod, setWeightMatrices, setWeightMatrix, trainByInstance, trainOnline, updateWeightMatrices, write, writeModelToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultilayerPerceptron

public MultilayerPerceptron()
The default constructor.


MultilayerPerceptron

public MultilayerPerceptron(String modelPath)
Initialize the MLP by specifying the location of the model.

Parameters:
modelPath - The path of the model.
Method Detail

train

public void train(int actual,
                  Vector instance)
Description copied from interface: OnlineLearner
Updates the model using a particular target variable value and a feature vector.

There may an assumption that if multiple passes through the training data are necessary, then the training examples will be presented in the same order. This is because the order of training examples may be used to assign records to different data splits for evaluation by cross-validation. Without the order invariance, records might be assigned to training and test splits and error estimates could be seriously affected.

If re-ordering is necessary, then using the alternative API which allows a tracking key to be added to the training example can be used.

Specified by:
train in interface OnlineLearner
Parameters:
actual - The value of the target variable. This value should be in the half-open interval [0..n) where n is the number of target categories.
instance - The feature vector for this example.

train

public void train(long trackingKey,
                  String groupKey,
                  int actual,
                  Vector instance)
Description copied from interface: OnlineLearner
Updates the model using a particular target variable value and a feature vector.

There may an assumption that if multiple passes through the training data are necessary that the tracking key for a record will be the same for each pass and that there will be a relatively large number of distinct tracking keys and that the low-order bits of the tracking keys will not correlate with any of the input variables. This tracking key is used to assign training examples to different test/training splits.

Examples of useful tracking keys include id-numbers for the training records derived from a database id for the base table from the which the record is derived, or the offset of the original data record in a data file.

Specified by:
train in interface OnlineLearner
Parameters:
trackingKey - The tracking key for this training example.
groupKey - An optional value that allows examples to be grouped in the computation of the update to the model.
actual - The value of the target variable. This value should be in the half-open interval [0..n) where n is the number of target categories.
instance - The feature vector for this example.

train

public void train(long trackingKey,
                  int actual,
                  Vector instance)
Description copied from interface: OnlineLearner
Updates the model using a particular target variable value and a feature vector.

There may an assumption that if multiple passes through the training data are necessary that the tracking key for a record will be the same for each pass and that there will be a relatively large number of distinct tracking keys and that the low-order bits of the tracking keys will not correlate with any of the input variables. This tracking key is used to assign training examples to different test/training splits.

Examples of useful tracking keys include id-numbers for the training records derived from a database id for the base table from the which the record is derived, or the offset of the original data record in a data file.

Specified by:
train in interface OnlineLearner
Parameters:
trackingKey - The tracking key for this training example.
actual - The value of the target variable. This value should be in the half-open interval [0..n) where n is the number of target categories.
instance - The feature vector for this example.

close

public void close()
Description copied from interface: OnlineLearner
Prepares the classifier for classification and deallocates any temporary data structures. An online classifier should be able to accept more training after being closed, but closing the classifier may make classification more efficient.

Specified by:
close in interface Closeable
Specified by:
close in interface OnlineLearner


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.