Neural Network Software

com.practicalstudies.neural
Class HyperbolicTangentFunction

java.lang.Object
  |
  +--com.practicalstudies.neural.HyperbolicTangentFunction
All Implemented Interfaces:
ActivationFunction, ErrorFunction

public class HyperbolicTangentFunction
extends java.lang.Object
implements ActivationFunction, ErrorFunction

Encapsulates the calculation of Node activation or output based on the hyperbolic tangent function, and of the error in output for the backpropagation training method using this function.

The hyperbolic tangent is a good choice for binary data.

Activation and error functions are combined in this class given that the error calculation for backpropagation is derived from the activation calculation.

Author:
Michael Wax
See Also:
ActivationFunction, ErrorFunction

Constructor Summary
HyperbolicTangentFunction()
          Constructor for a function with a steepness of 1.
HyperbolicTangentFunction(double steepness)
          Constructor for a function with a specified steepness.
 
Method Summary
 double calculateActivation(double weightedInput)
          Calculates neuron activation as the hyperbolic tangent function a*tanh(bx), equivalent to 2/(1 + e-(bv)) - 1 which returns values in [-1,1], with a value of 0 at the value specified by the threshold.
 double calculateError(double calculatedValue, double actualValue)
          Calculate the error in Neuron output relative to an actual value (useful for neurons in an output layer).
 double calculateError(double calculatedValue, java.util.List outputConnections)
          Calculate the error in Neuron output based on errors observed in the outputs of Neurons which rely on the output of this Neuron.
 double getSteepness()
           
 void setSteepness(double steepness)
          Specify the steepness parameter of the logistic function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HyperbolicTangentFunction

public HyperbolicTangentFunction()
Constructor for a function with a steepness of 1.

See Also:
setSteepness

HyperbolicTangentFunction

public HyperbolicTangentFunction(double steepness)
Constructor for a function with a specified steepness.

See Also:
setSteepness
Method Detail

getSteepness

public double getSteepness()

setSteepness

public void setSteepness(double steepness)

Specify the steepness parameter of the logistic function.

A value of one (the default) is typical. Values smaller than one will make the function less steep, and values greater than one more steep. An infinite value would yield a step function.


calculateActivation

public double calculateActivation(double weightedInput)
Calculates neuron activation as the hyperbolic tangent function a*tanh(bx), equivalent to 2/(1 + e-(bv)) - 1 which returns values in [-1,1], with a value of 0 at the value specified by the threshold.

Specified by:
calculateActivation in interface ActivationFunction

calculateError

public double calculateError(double calculatedValue,
                             double actualValue)
Calculate the error in Neuron output relative to an actual value (useful for neurons in an output layer).

Specified by:
calculateError in interface ErrorFunction
Parameters:
calculatedValue - the calculated output of the Neuron
actualValue - the expected output of the Neuron

calculateError

public double calculateError(double calculatedValue,
                             java.util.List outputConnections)
Calculate the error in Neuron output based on errors observed in the outputs of Neurons which rely on the output of this Neuron.

Specified by:
calculateError in interface ErrorFunction
Parameters:
calculatedValue - the calculated output of the Neuron
outputConnections - a List of WeightedConnections to Neurons which receive the output of this Neuron

PracticalStudies.com