org.encog.engine.network.activation
Class ActivationRamp

java.lang.Object
  extended by org.encog.engine.network.activation.ActivationRamp
All Implemented Interfaces:
Serializable, Cloneable, ActivationFunction

public class ActivationRamp
extends Object
implements ActivationFunction

A ramp activation function. This function has a high and low threshold. If the high threshold is exceeded a fixed value is returned. Likewise, if the low value is exceeded another fixed value is returned.

See Also:
Serialized Form

Field Summary
static int PARAM_RAMP_HIGH
          The ramp high parameter.
static int PARAM_RAMP_HIGH_THRESHOLD
          The ramp high threshold parameter.
static int PARAM_RAMP_LOW
          The ramp low parameter.
static int PARAM_RAMP_LOW_THRESHOLD
          The ramp low threshold parameter.
 
Constructor Summary
ActivationRamp()
          Default constructor.
ActivationRamp(double thresholdHigh, double thresholdLow, double high, double low)
          Construct a ramp activation function.
 
Method Summary
 void activationFunction(double[] x, int start, int size)
          Implements the activation function.
 ActivationFunction clone()
          Clone the object.
 double derivativeFunction(double d)
          Calculate the derivative of the activation.
 double getHigh()
           
 double getLow()
           
 String getOpenCLExpression(boolean derivative)
          Returns the OpenCL expression for this activation function.
 String[] getParamNames()
          
 double[] getParams()
          
 double getThresholdHigh()
           
 double getThresholdLow()
           
 boolean hasDerivative()
           
 void setHigh(double d)
          Set the high value.
 void setLow(double d)
          Set the low value.
 void setParam(int index, double value)
          Set one of the params for this activation function.
 void setThresholdHigh(double d)
          Set the threshold high.
 void setThresholdLow(double d)
          Set the threshold low.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_RAMP_HIGH_THRESHOLD

public static final int PARAM_RAMP_HIGH_THRESHOLD
The ramp high threshold parameter.

See Also:
Constant Field Values

PARAM_RAMP_LOW_THRESHOLD

public static final int PARAM_RAMP_LOW_THRESHOLD
The ramp low threshold parameter.

See Also:
Constant Field Values

PARAM_RAMP_HIGH

public static final int PARAM_RAMP_HIGH
The ramp high parameter.

See Also:
Constant Field Values

PARAM_RAMP_LOW

public static final int PARAM_RAMP_LOW
The ramp low parameter.

See Also:
Constant Field Values
Constructor Detail

ActivationRamp

public ActivationRamp(double thresholdHigh,
                      double thresholdLow,
                      double high,
                      double low)
Construct a ramp activation function.

Parameters:
thresholdHigh - The high threshold value.
thresholdLow - The low threshold value.
high - The high value, replaced if the high threshold is exceeded.
low - The low value, replaced if the low threshold is exceeded.

ActivationRamp

public ActivationRamp()
Default constructor.

Method Detail

clone

public ActivationFunction clone()
Clone the object.

Specified by:
clone in interface ActivationFunction
Overrides:
clone in class Object
Returns:
The cloned object.

getHigh

public double getHigh()
Returns:
the high

getLow

public double getLow()
Returns:
the low

getThresholdHigh

public double getThresholdHigh()
Returns:
the thresholdHigh

getThresholdLow

public double getThresholdLow()
Returns:
the thresholdLow

hasDerivative

public boolean hasDerivative()
Specified by:
hasDerivative in interface ActivationFunction
Returns:
True, as this function does have a derivative.

setThresholdLow

public void setThresholdLow(double d)
Set the threshold low.

Parameters:
d - The threshold low.

setThresholdHigh

public void setThresholdHigh(double d)
Set the threshold high.

Parameters:
d - The threshold high.

setLow

public void setLow(double d)
Set the low value.

Parameters:
d - The low value.

setHigh

public void setHigh(double d)
Set the high value.

Parameters:
d - The high value.

activationFunction

public void activationFunction(double[] x,
                               int start,
                               int size)
Implements the activation function. The array is modified according to the activation function being used. See the class description for more specific information on this type of activation function.

Specified by:
activationFunction in interface ActivationFunction
Parameters:
x - The input array to the activation function.
start - The starting index.
size - The number of values to calculate.

derivativeFunction

public double derivativeFunction(double d)
Calculate the derivative of the activation. It is assumed that the value d, which is passed to this method, was the output from this activation. This prevents this method from having to recalculate the activation, just to recalculate the derivative. The array is modified according derivative of the activation function being used. See the class description for more specific information on this type of activation function. Propagation training requires the derivative. Some activation functions do not support a derivative and will throw an error.

Specified by:
derivativeFunction in interface ActivationFunction
Parameters:
d - The input array to the activation function.
Returns:
The derivative.

getParamNames

public String[] getParamNames()

Specified by:
getParamNames in interface ActivationFunction
Returns:
The names of the parameters.

getParams

public double[] getParams()

Specified by:
getParams in interface ActivationFunction
Returns:
The params for this activation function.

setParam

public void setParam(int index,
                     double value)
Set one of the params for this activation function.

Specified by:
setParam in interface ActivationFunction
Parameters:
index - The index of the param to set.
value - The value to set.

getOpenCLExpression

public String getOpenCLExpression(boolean derivative)
Returns the OpenCL expression for this activation function.

Specified by:
getOpenCLExpression in interface ActivationFunction
Parameters:
derivative - True if we want the derivative, false otherwise.
Returns:
The OpenCL expression for this activation function.


Copyright © 2011. All Rights Reserved.