org.encog.engine.network.activation
Class ActivationReLU
- java.lang.Object
-
- org.encog.engine.network.activation.ActivationReLU
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, ActivationFunction
public class ActivationReLU extends java.lang.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
Fields Modifier and Type Field and Description static intPARAM_RELU_LOWThe ramp low parameter.static intPARAM_RELU_LOW_THRESHOLDThe ramp low threshold parameter.
-
Constructor Summary
Constructors Constructor and Description ActivationReLU()Default constructor.ActivationReLU(double thresholdLow, double low)Construct a ramp 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()Clone the object.doublederivativeFunction(double b, double a)Calculate the derivative.java.lang.StringgetFactoryCode()java.lang.StringgetLabel()doublegetLow()java.lang.String[]getParamNames()double[]getParams()doublegetThresholdLow()booleanhasDerivative()voidsetLow(double d)Set the low value.voidsetParam(int index, double value)Set one of the params for this activation function.voidsetThresholdLow(double d)Set the threshold low.
-
-
-
Field Detail
-
PARAM_RELU_LOW_THRESHOLD
public static final int PARAM_RELU_LOW_THRESHOLD
The ramp low threshold parameter.- See Also:
- Constant Field Values
-
PARAM_RELU_LOW
public static final int PARAM_RELU_LOW
The ramp low parameter.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ActivationReLU
public ActivationReLU()
Default constructor.
-
ActivationReLU
public ActivationReLU(double thresholdLow, double low)Construct a ramp activation function.- Parameters:
thresholdLow- The low threshold value.low- The low value, replaced if the low threshold is exceeded.
-
-
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()
Clone the object.- Specified by:
clonein interfaceActivationFunction- Overrides:
clonein classjava.lang.Object- Returns:
- The cloned 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.
-
getLow
public final double getLow()
- Returns:
- the low
-
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.
-
getThresholdLow
public final double getThresholdLow()
- Returns:
- the thresholdLow
-
hasDerivative
public final boolean hasDerivative()
- Specified by:
hasDerivativein interfaceActivationFunction- Returns:
- True, as this function does have a derivative.
-
setLow
public final void setLow(double d)
Set the low value.- Parameters:
d- The low value.
-
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.
-
setThresholdLow
public final void setThresholdLow(double d)
Set the threshold low.- Parameters:
d- The threshold low.
-
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