Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.neuroph.core.learning
Class SupervisedLearning

    java.lang.Object
      org.neuroph.core.learning.LearningRule
          org.neuroph.core.learning.IterativeLearning
              org.neuroph.core.learning.SupervisedLearning

All Implemented Interfaces:
  Serializable

Direct Known Subclasses:
  LMS, SimulatedAnnealingLearning

    public abstract class SupervisedLearning

extends IterativeLearning
implements Serializable

Base class for all supervised learning algorithms. It extends IterativeLearning, and provides general supervised learning principles.

Author:
  Zoran Sevarac
See Also:
  Serialized Form

Field Summary
`protected double` | `maxError` Max allowed network error (condition to stop learning)
`protected double[]` | `outputError` Stores network output error vector
`protected double` | `previousEpochError` Total network error in previous epoch
`protected double` | `totalNetworkError` Total network error
`protected double` | `totalSquaredErrorSum` Total squared sum of all pattern errors

Fields inherited from class org.neuroph.core.learning.IterativeLearning
`currentIteration, iterationsLimited, learningRate, maxIterations`

Fields inherited from class org.neuroph.core.learning.LearningRule
`listeners, neuralNetwork`

Constructor Summary
`SupervisedLearning()` Creates new supervised learning rule

Method Summary
`protected void` | `addToSquaredErrorSum(double[] outputError)` Calculates and updates sum of squared errors for single pattern, and updates total sum of squared pattern errors
`protected void` | `afterEpoch()`
`protected void` | `beforeEpoch()`
`protected double[]` | `calculateOutputError(double[] desiredOutput, double[] output)` Calculates the network error for the current input pattern - diference between desired and actual output
`protected void` | `doBatchWeightsUpdate()` This method updates network weights in batch mode - use accumulated weights change stored in Weight.deltaWeight It is executed after each learning epoch, only if learning is done in batch mode.
`void` | `doLearningEpoch(DataSet trainingSet)` This method implements basic logic for one learning epoch for the supervised learning algorithms.
`protected boolean` | `errorChangeStalled()` Returns true if absolute error change is sufficently small (<=minErrorChange) for minErrorChangeStopIterations number of iterations
`double` | `getMaxError()` Returns learning error tolerance - the value of total network error to stop learning.
`double` | `getMinErrorChange()` Returns min error change stopping criteria
`int` | `getMinErrorChangeIterationsCount()` Returns number of iterations count for for min error change stopping criteria
`int` | `getMinErrorChangeIterationsLimit()` Returns number of iterations for min error change stopping criteria
`double` | `getPreviousEpochError()` Returns total network error in previous learning epoch
`double` | `getTotalNetworkError()` Returns total network error in current learning epoch
`protected boolean` | `hasReachedStopCondition()` Returns true if stop condition has been reached, false otherwise.
`boolean` | `isInBatchMode()` Returns true if learning is performed in batch mode, false otherwise
`void` | `learn(DataSet trainingSet, double maxError)` Trains network for the specified training set and number of iterations
`void` | `learn(DataSet trainingSet, double maxError, int maxIterations)` Trains network for the specified training set and number of iterations
`protected void` | `learnPattern(DataSetRow trainingElement)` Trains network with the input and desired output pattern from the specified training element
`protected void` | `onStart()` This method is executed when learning starts, before the first epoch.
`void` | `setBatchMode(boolean batchMode)` Sets batch mode on/off (true/false)
`void` | `setMaxError(double maxError)` Sets allowed network error, which indicates when to stopLearning training
`void` | `setMinErrorChange(double minErrorChange)` Sets min error change stopping criteria
`void` | `setMinErrorChangeIterationsLimit(int minErrorChangeIterationsLimit)` Sets number of iterations for min error change stopping criteria
`protected abstract void` | `updateNetworkWeights(double[] outputError)` This method should implement the weights update procedure for the whole network for the given output error vector.

Methods inherited from class org.neuroph.core.learning.IterativeLearning
`doOneLearningIteration, getCurrentIteration, getLearningRate, isPausedLearning, learn, learn, pause, resume, setLearningRate, setMaxIterations`

Methods inherited from class org.neuroph.core.learning.LearningRule
`addListener, fireLearningEvent, getNeuralNetwork, getTrainingSet, isStopped, removeListener, setNeuralNetwork, setTrainingSet, stopLearning`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### totalNetworkError

    protected transient double totalNetworkError

  Total network error

### totalSquaredErrorSum

    protected transient double totalSquaredErrorSum

  Total squared sum of all pattern errors

### previousEpochError

    protected transient double previousEpochError

  Total network error in previous epoch

### maxError

    protected double maxError

  Max allowed network error (condition to stop learning)

### outputError

    protected double[] outputError

  Stores network output error vector

Constructor Detail

### SupervisedLearning

    public SupervisedLearning()

  Creates new supervised learning rule

Method Detail

### learn

    public void learn(DataSet trainingSet,
                      double maxError)

  Trains network for the specified training set and number of iterations

  Parameters:
    `trainingSet` - training set to learn
    `maxError` - maximum number of iterations to learn

### learn

    public void learn(DataSet trainingSet,
                      double maxError,
                      int maxIterations)

  Trains network for the specified training set and number of iterations

  Parameters:
    `trainingSet` - training set to learn
    `maxIterations` - maximum number of learning iterations

### onStart

    protected void onStart()

  Description copied from class: `IterativeLearning`
  This method is executed when learning starts, before the first epoch. Used for initialisation.

  Overrides:
    `onStart` in class `IterativeLearning`

### beforeEpoch

    protected void beforeEpoch()

  Overrides:
    `beforeEpoch` in class `IterativeLearning`

### afterEpoch

    protected void afterEpoch()

  Overrides:
    `afterEpoch` in class `IterativeLearning`

### doLearningEpoch

    public void doLearningEpoch(DataSet trainingSet)

  This method implements basic logic for one learning epoch for the supervised learning algorithms. Epoch is the one pass through the training set. This method iterates through the training set and trains network for each element. It also sets flag if conditions to stop learning has been reached: network error below some allowed value, or maximum iteration count

  Specified by:
    `doLearningEpoch` in class `IterativeLearning`
  Parameters:
    `trainingSet` - training set for training network

### learnPattern

    protected void learnPattern(DataSetRow trainingElement)

  Trains network with the input and desired output pattern from the specified training element

  Parameters:
    `trainingElement` - supervised training element which contains input and desired output

### doBatchWeightsUpdate

    protected void doBatchWeightsUpdate()

  This method updates network weights in batch mode - use accumulated weights change stored in Weight.deltaWeight It is executed after each learning epoch, only if learning is done in batch mode.

  See Also:
    `SupervisedLearning#doLearningEpoch(org.neuroph.core.learning.TrainingSet)`

### hasReachedStopCondition

    protected boolean hasReachedStopCondition()

  Returns true if stop condition has been reached, false otherwise. Override this method in derived classes to implement custom stop criteria.

  Returns:
    true if stop condition is reached, false otherwise

### errorChangeStalled

    protected boolean errorChangeStalled()

  Returns true if absolute error change is sufficently small (<=minErrorChange) for minErrorChangeStopIterations number of iterations

  Returns:
    true if absolute error change is stalled (error is sufficently small for some number of iterations)

### calculateOutputError

    protected double[] calculateOutputError(double[] desiredOutput,
                                            double[] output)

  Calculates the network error for the current input pattern - diference between desired and actual output

  Parameters:
    `output` - actual network output
    `desiredOutput` - desired network output
  Returns:
    pattern error

### isInBatchMode

    public boolean isInBatchMode()

  Returns true if learning is performed in batch mode, false otherwise

  Returns:
    true if learning is performed in batch mode, false otherwise

### setBatchMode

    public void setBatchMode(boolean batchMode)

  Sets batch mode on/off (true/false)

  Parameters:
    `batchMode` - batch mode setting

### setMaxError

    public void setMaxError(double maxError)

  Sets allowed network error, which indicates when to stopLearning training

  Parameters:
    `maxError` - network error

### getMaxError

    public double getMaxError()

  Returns learning error tolerance - the value of total network error to stop learning.

  Returns:
    learning error tolerance

### getTotalNetworkError

    public double getTotalNetworkError()

  Returns total network error in current learning epoch

  Returns:
    total network error in current learning epoch

### getPreviousEpochError

    public double getPreviousEpochError()

  Returns total network error in previous learning epoch

  Returns:
    total network error in previous learning epoch

### getMinErrorChange

    public double getMinErrorChange()

  Returns min error change stopping criteria

  Returns:
    min error change stopping criteria

### setMinErrorChange

    public void setMinErrorChange(double minErrorChange)

  Sets min error change stopping criteria

  Parameters:
    `minErrorChange` - value for min error change stopping criteria

### getMinErrorChangeIterationsLimit

    public int getMinErrorChangeIterationsLimit()

  Returns number of iterations for min error change stopping criteria

  Returns:
    number of iterations for min error change stopping criteria

### setMinErrorChangeIterationsLimit

    public void setMinErrorChangeIterationsLimit(int minErrorChangeIterationsLimit)

  Sets number of iterations for min error change stopping criteria

  Parameters:
    `minErrorChangeIterationsLimit` - number of iterations for min error change stopping criteria

### getMinErrorChangeIterationsCount

    public int getMinErrorChangeIterationsCount()

  Returns number of iterations count for for min error change stopping criteria

  Returns:
    number of iterations count for for min error change stopping criteria

### addToSquaredErrorSum

    protected void addToSquaredErrorSum(double[] outputError)

  Calculates and updates sum of squared errors for single pattern, and updates total sum of squared pattern errors

  Parameters:
    `outputError` - output error vector

### updateNetworkWeights

    protected abstract void updateNetworkWeights(double[] outputError)

  This method should implement the weights update procedure for the whole network for the given output error vector.

  Parameters:
    `outputError` - output error vector for some network input (aka. patternError, network error) usually the difference between desired and actual output
  See Also:
    `calculateOutputError`, `addToSquaredErrorSum(double[])`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012. All Rights Reserved.