org.encog.engine.network.activation
Class ActivationStep
- java.lang.Object
-
- org.encog.engine.network.activation.ActivationStep
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, ActivationFunction
public class ActivationStep extends java.lang.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 0. 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
Fields Modifier and Type Field and Description static intPARAM_STEP_CENTERThe step center parameter.static intPARAM_STEP_HIGHThe step high parameter.static intPARAM_STEP_LOWThe step low parameter.
-
Constructor Summary
Constructors Constructor and Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidactivationFunction(double[] x, int start, int size)Implements the activation function.ActivationFunctionclone()doublederivativeFunction(double b, double a)Calculate the derivative.doublegetCenter()java.lang.StringgetFactoryCode()doublegetHigh()java.lang.StringgetLabel()doublegetLow()java.lang.String[]getParamNames()double[]getParams()booleanhasDerivative()voidsetCenter(double d)Set the center of this function.voidsetHigh(double d)Set the high of this function.voidsetLow(double d)Set the low of this function.voidsetParam(int index, double value)Set one of the params for this activation function.
-
-
-
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()
Create a basic step activation with low=0, center=0, high=1.
-
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.
-
-
Method Detail
-
activationFunction
public final 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:
activationFunctionin interfaceActivationFunction- Parameters:
x- The input array to the activation function.start- The starting index.size- The number of values to calculate.
-
clone
public final ActivationFunction clone()
- Specified by:
clonein interfaceActivationFunction- Overrides:
clonein classjava.lang.Object- Returns:
- A clone of this object.
-
derivativeFunction
public final double derivativeFunction(double b, double a)Calculate the derivative. For performance reasons two numbers are provided. First, the value "b" is simply the number that we would like to calculate the derivative of. Second, the value "a", which is the value returned by the activation function, when presented with "b". We use two values because some of the most common activation functions make use of the result of the activation function. It is bad for performance to calculate this value twice. Yet, not all derivatives are calculated this way. By providing both the value before the activation function is applied ("b"), and after the activation function is applied("a"), the class can be constructed to use whichever value will be the most efficient.- Specified by:
derivativeFunctionin interfaceActivationFunction- Parameters:
b- The number to calculate the derivative of, the number "before" the activation function was applied.a- The number "after" an activation function has been applied.- Returns:
- The derivative.
-
getCenter
public final double getCenter()
- Returns:
- The center.
-
getHigh
public final double getHigh()
- Returns:
- The high value.
-
getLow
public final double getLow()
- Returns:
- The low value.
-
getParamNames
public final java.lang.String[] getParamNames()
- Specified by:
getParamNamesin interfaceActivationFunction- Returns:
- The names of the parameters.
-
getParams
public final double[] getParams()
- Specified by:
getParamsin interfaceActivationFunction- Returns:
- The params for this activation function.
-
hasDerivative
public final boolean hasDerivative()
- Specified by:
hasDerivativein interfaceActivationFunction- Returns:
- Returns true, this activation function has a derivative.
-
setCenter
public final void setCenter(double d)
Set the center of this function.- Parameters:
d- The center of this function.
-
setHigh
public final void setHigh(double d)
Set the high of this function.- Parameters:
d- The high of this function.
-
setLow
public final void setLow(double d)
Set the low of this function.- Parameters:
d- The low of this function.
-
setParam
public final void setParam(int index, double value)Set one of the params for this activation function.- Specified by:
setParamin interfaceActivationFunction- Parameters:
index- The index of the param to set.value- The value to set.
-
getFactoryCode
public java.lang.String getFactoryCode()
- Specified by:
getFactoryCodein interfaceActivationFunction- Returns:
- The string for the Encog factory code. Return null if you do not care to be support for creating of your activation through factory.
-
getLabel
public java.lang.String getLabel()
- Specified by:
getLabelin interfaceActivationFunction- Returns:
- The human-friendly name for this activation
-
-
DMelt 3.0 © DataMelt by jWork.ORG