Learner

dbn.classifier.neural

## Class Learner

- java.lang.Object
- - mulan.classifier.MultiLabelLearnerBase
  - - dbn.classifier.neural.Learner

- All Implemented Interfaces:
    java.io.Serializable, mulan.classifier.MultiLabelLearner, weka.core.TechnicalInformationHandler
  Direct Known Subclasses:
    DBLearner

      public abstract class Learner
      extends mulan.classifier.MultiLabelLearnerBase

  An abstract control class for `DeepBeliefNetwork`. Trains the neural network and can make prediction. it has only the necessary fields and some getter and setter methods. The implementation of this class is the class `DBLearner`.
  See Also:
    `DeepBeliefNetwork`, `MultiLabelLearnerBase`, Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `_bpEpochs` The number of back-propagation epochs.
    `protected int` | `_greedyEpochs` The number of epochs per RBM.
    `protected DeepBeliefNetwork` | `_nn` The `DeepBeliefNetwork` that the Learner will train.
    `protected double` | `_threshold` This field is used to convert the output (double array) of the neural network in a bipartition array.

    - ### Fields inherited from class mulan.classifier.MultiLabelLearnerBase

      `featureIndices, labelIndices, numLabels`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Learner()` The constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getEpochs()` Gets number of training epochs.
    `DeepBeliefNetwork` | `getLeanedDBN()` Returns the `DeepBeliefNetwork`.
    `double` | `getLearningRate()` Gets the learning rate.
    `double` | `getMomentum()` Gets the momentum.
    `double` | `getThreshold()` Gets the threshold.
    `double` | `getWeightCost()` Gets a value of the regularization cost term for weights decay.
    `boolean` | `isSetNN()` Informs if the neural network has been set.
    `mulan.classifier.MultiLabelOutput[]` | `makePrediction(weka.core.Instances instances)` This method uses the `makePrediction(Instance instnc)` method to predict multiple `Instances` returning an array of `MultiLabelOutput`.
    `void` | `setBPEpochs(int epochs)` Sets the number of training epochs.
    `void` | `setDBN(DeepBeliefNetwork dbn)` Sets the `DeepBeliefNetwork`.
    `void` | `setLearningRate(double learningRate)` Sets the learning rate.
    `void` | `setMomentum(double momentum)` Sets the momentum value that specifies the training urge.
    `void` | `setPreTrainingEpochs(int epochsPerLayer)` Sets the number of training epochs for every `RBM` during the un-supervised learning.
    `void` | `setThreshold(double threshold)` Sets the threshold that is used for the bipartition.
    `void` | `setWeightCost(double weightCost)` Sets the regularization cost term for weights decay.

    - ### Methods inherited from class mulan.classifier.MultiLabelLearnerBase

      `build, buildInternal, debug, getDebug, getTechnicalInformation, globalInfo, isModelInitialized, isUpdatable, makeCopy, makePrediction, makePredictionInternal, setDebug`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _bpEpochs

          protected int _bpEpochs

      The number of back-propagation epochs. This is the number of the training iterations. The training set will pass through the classifier `_bpEpochs` times for better performance during the supervised training task.

    - #### _greedyEpochs

          protected int _greedyEpochs

      The number of epochs per RBM. This field specifies how many iterations will the `RBMImpl` do during the un-supervised training task.

    - #### _threshold

          protected double _threshold

      This field is used to convert the output (double array) of the neural network in a bipartition array.
      If the value of a label is more than the value threshold, the corresponding bipartition layer will have positive value
      On the other hand, if the value of the label is less than the value of the threshold, the corresponding bipartition layer will have negative value

    - #### _nn

          protected DeepBeliefNetwork _nn

      The `DeepBeliefNetwork` that the Learner will train. When the neural network will be trained, user can get it with the `getLearnedDBN()` function.

  - ### Constructor Detail

    - #### Learner

          public Learner()

      The constructor. Initializes the default values for some necessary fields.

  - ### Method Detail

    - #### setDBN

          public void setDBN(DeepBeliefNetwork dbn)

      Sets the `DeepBeliefNetwork`. If the networks is null, it throws an exception.
      Parameters:
        `dbn` -
      Throws:
        `{@link` - NullPointerException} when the dbn is null

    - #### setBPEpochs

          public void setBPEpochs(int epochs)

      Sets the number of training epochs. Must be greater than 0.
      Default value is 10.
      Parameters:
        `epochs` - the number of training epochs
      Throws:
        `java.lang.IllegalArgumentException` - if passed value is invalid

    - #### setPreTrainingEpochs

          public void setPreTrainingEpochs(int epochsPerLayer)

      Sets the number of training epochs for every `RBM` during the un-supervised learning. Must be greater than 0.
      Default value is 100.
      Parameters:
        `epochsPerLayer` - the number of training epochs per `RBM`
      Throws:
        `java.lang.IllegalArgumentException` - if passed value is invalid

    - #### setMomentum

          public void setMomentum(double momentum)

      Sets the momentum value that specifies the training urge. Must be greater than 0 and no more than 1.
      Default value is 0.6.
      Parameters:
        `momentum` - the momentum
      Throws:
        `java.lang.IllegalArgumentException` - if passed value is invalid

    - #### setLearningRate

          public void setLearningRate(double learningRate)

      Sets the learning rate. Must be greater than 0 and no more than 1.
      Default value is 0.05.
      Parameters:
        `learningRate` - the learning rate
      Throws:
        `java.lang.IllegalArgumentException` - if passed value is invalid

    - #### setWeightCost

          public void setWeightCost(double weightCost)

      Sets the regularization cost term for weights decay. Must be greater than 0 and no more than 1.
      Default value is 0.00001.
      Parameters:
        `weightCost` - the weights decay cost term
      Throws:
        `java.lang.IllegalArgumentException` - if passed value is invalid

    - #### setThreshold

          public void setThreshold(double threshold)

      Sets the threshold that is used for the bipartition. Must be greater than 0 and no more than 1.
      Default value is -1.
      Parameters:
        `threshold` - the threshold
      Throws:
        `java.lang.IllegalArgumentException` - if passed value is invalid

    - #### getEpochs

          public int getEpochs()

      Gets number of training epochs. Default value is 20.
      Returns:
        training epochs

    - #### getMomentum

          public double getMomentum()

      Gets the momentum. The default value is 0.6.
      Returns:
        momentum

    - #### getLearningRate

          public double getLearningRate()

      Gets the learning rate. The default value is 0.05.
      Returns:
        learning rate

    - #### getWeightCost

          public double getWeightCost()

      Gets a value of the regularization cost term for weights decay.
      Returns:
        regularization cost

    - #### getThreshold

          public double getThreshold()

      Gets the threshold. The default value is -1.
      Returns:
        threshold
      Throws:
        `java.lang.NullPointerException` - if threshold has not set

    - #### isSetNN

          public boolean isSetNN()

      Informs if the neural network has been set.
      Returns:
        `true` if the DBN has been set
        `false` if the DBN has not been set

    - #### getLeanedDBN

          public DeepBeliefNetwork getLeanedDBN()
                                         throws java.lang.NullPointerException

      Returns the `DeepBeliefNetwork`. It throws a `NullPointerException` when the neural network has not been set.
      Returns:
        the learned `DeepBeliefNetwork`
      Throws:
        `java.lang.NullPointerException`

    - #### makePrediction

          public mulan.classifier.MultiLabelOutput[] makePrediction(weka.core.Instances instances)
                                                             throws java.lang.Exception

      This method uses the `makePrediction(Instance instnc)` method to predict multiple `Instances` returning an array of `MultiLabelOutput`.
      It throws an `Exception` when a data format problem is occurred
      Parameters:
        `instances` - the testing dataset
      Returns:
        an array of `MultiLabelOutput` objects, one for each instance
      Throws:
        `java.lang.Exception`