org.encog.engine.network.activation
Class ActivationStep

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

public class ActivationStep
extends Object
implements ActivationFunction

The step activation function is a very simple activation function. It is the activation function that was used by the original perceptron. Using the default parameters it will return 1 if the input is 0 or greater. Otherwise it will return 1. The center, low and high properties allow you to define how this activation function works. If the input is equal to center or higher the high property value will be returned, otherwise the low property will be returned. This activation function does not have a derivative, and can not be used with propagation training, or any other training that requires a derivative.

See Also:
Serialized Form

Field Summary
static int PARAM_STEP_CENTER
          The step center parameter.
static int PARAM_STEP_HIGH
          The step high parameter.
static int PARAM_STEP_LOW
          The step low parameter.
 
Constructor Summary
ActivationStep()
          Create a basic step activation with low=0, center=0, high=1.
ActivationStep(double low, double center, double high)
          Construct a step activation function.
 
Method Summary
 void activationFunction(double[] x, int start, int size)
          Implements the activation function.
 ActivationFunction clone()
           
 double derivativeFunction(double d)
          Calculate the derivative of the activation.
 double getCenter()
           
 double getHigh()
           
 double getLow()
           
 String getOpenCLExpression(boolean derivative)
          Returns the OpenCL expression for this activation function.
 String[] getParamNames()
          
 double[] getParams()
          
 boolean hasDerivative()
           
 void setCenter(double d)
          Set the center of this function.
 void setHigh(double d)
          Set the high of this function.
 void setLow(double d)
          Set the low of this function.
 void setParam(int index, double value)
          Set one of the params for this activation function.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_STEP_CENTER

public static final int PARAM_STEP_CENTER
The step center parameter.

See Also:
Constant Field Values

PARAM_STEP_LOW

public static final int PARAM_STEP_LOW
The step low parameter.

See Also:
Constant Field Values

PARAM_STEP_HIGH

public static final int PARAM_STEP_HIGH
The step high parameter.

See Also:
Constant Field Values
Constructor Detail

ActivationStep

public ActivationStep(double low,
                      double center,
                      double high)
Construct a step activation function.

Parameters:
low - The low of the function.
center - The center of the function.
high - The high of the function.

ActivationStep

public ActivationStep()
Create a basic step activation with low=0, center=0, high=1.

Method Detail

getCenter

public double getCenter()
Returns:
The center.

getLow

public double getLow()
Returns:
The low value.

getHigh

public double getHigh()
Returns:
The high value.

clone

public ActivationFunction clone()
Specified by:
clone in interface ActivationFunction
Overrides:
clone in class Object
Returns:
A clone of this object.

hasDerivative

public boolean hasDerivative()
Specified by:
hasDerivative in interface ActivationFunction
Returns:
Returns true, this activation function has a derivative.

setCenter

public void setCenter(double d)
Set the center of this function.

Parameters:
d - The center of this function.

setHigh

public void setHigh(double d)
Set the high of this function.

Parameters:
d - The high of this function.

setLow

public void setLow(double d)
Set the low of this function.

Parameters:
d - The low of this function.

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.