The Encog Project

org.encog.neural.prune
Class Prune

java.lang.Object
  extended by org.encog.neural.prune.Prune

public class Prune
extends java.lang.Object

Prune: The prune class provides some basic help for determining the correct number of neurons to put in a hidden layer. Two types of prune are supported. Selective - Try removing neurons from the hidden layers and if the affect on the accuracy of the neural network is not great then make the removal permanent. Incremental - Start with one neuron in the hidden layer and increase until the neural network error is acceptable.


Field Summary
static int MAX_TRY
          Maximum number of tries.
static double ONE_PERCENT
          One percent.
 
Constructor Summary
Prune(BasicNetwork network, NeuralDataSet training, double maxError)
          Constructor that is designed to setup for a selective prune.
Prune(double rate, double momentum, NeuralDataSet training, double maxError)
          Constructor used to setup the prune object for an incremental prune.
 
Method Summary
protected  BasicNetwork clipHiddenNeuron(int neuron)
          Internal method used to clip the hidden neurons.
protected  double determineError(BasicNetwork network)
          Internal method to determine the error for a neural network.
protected  boolean findNeuron()
          Internal method that will loop through all hidden neurons and prune them if pruning the neuron does not cause too great of an increase in error.
 BasicNetwork getCurrentNetwork()
          Get the current neural network.
 int getCycles()
          Called to get the current number of cycles.
 boolean getDone()
          Called to determine if we are done in an incremental prune.
 double getError()
          Called to get the current error.
protected  int getHiddenCount()
          The current number of hidden neurons being evaluated.
 double getHiddenNeuronCount()
          Get the number of hidden neurons.
protected  void increment()
          Internal method that is called at the end of each incremental cycle.
 void pruneIncramental()
          Method that is called to prune the neural network incramentaly.
 int pruneSelective()
          Called to complete the selective pruning process.
 void startIncremental()
          Method that is called to start the incremental prune process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_TRY

public static final int MAX_TRY
Maximum number of tries.

See Also:
Constant Field Values

ONE_PERCENT

public static final double ONE_PERCENT
One percent.

See Also:
Constant Field Values
Constructor Detail

Prune

public Prune(BasicNetwork network,
             NeuralDataSet training,
             double maxError)
Constructor that is designed to setup for a selective prune.

Parameters:
network - The neural network that we wish to prune.
training - The training set to use.
maxError - The max error allowed.

Prune

public Prune(double rate,
             double momentum,
             NeuralDataSet training,
             double maxError)
Constructor used to setup the prune object for an incremental prune.

Parameters:
rate - The desired learning rate.
momentum - The desired momentum.
training - The training data.
maxError - The max error that is acceptable.
Method Detail

clipHiddenNeuron

protected BasicNetwork clipHiddenNeuron(int neuron)
Internal method used to clip the hidden neurons.

Parameters:
neuron - The neuron to clip.
Returns:
Returns the new neural network.

determineError

protected double determineError(BasicNetwork network)
Internal method to determine the error for a neural network.

Parameters:
network - The neural network that we are seeking a error rate for.
Returns:
The error for the specified neural network.

findNeuron

protected boolean findNeuron()
Internal method that will loop through all hidden neurons and prune them if pruning the neuron does not cause too great of an increase in error.

Returns:
True if a prune was made, false otherwise.

getCurrentNetwork

public BasicNetwork getCurrentNetwork()
Get the current neural network.

Returns:
The neural network.

getCycles

public int getCycles()
Called to get the current number of cycles.

Returns:
The current number of cycles.

getDone

public boolean getDone()
Called to determine if we are done in an incremental prune.

Returns:
Returns true if we are done, false otherwise.

getError

public double getError()
Called to get the current error.

Returns:
The current error.

getHiddenCount

protected int getHiddenCount()
The current number of hidden neurons being evaluated.

Returns:
The current number of hidden neurons.

getHiddenNeuronCount

public double getHiddenNeuronCount()
Get the number of hidden neurons.

Returns:
The number of hidden neurons.

increment

protected void increment()
Internal method that is called at the end of each incremental cycle.


pruneIncramental

public void pruneIncramental()
Method that is called to prune the neural network incramentaly.


pruneSelective

public int pruneSelective()
Called to complete the selective pruning process.

Returns:
The number of neurons that were pruned.

startIncremental

public void startIncremental()
Method that is called to start the incremental prune process.


The Encog Project