org.encog.engine.network.activation
Class ActivationLinear

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

public class ActivationLinear
extends Object
implements ActivationFunction

The Linear layer is really not an activation function at all. The input is simply passed on, unmodified, to the output. This activation function is primarily theoretical and of little actual use. Usually an activation function that scales between 0 and 1 or -1 and 1 should be used.

See Also:
Serialized Form

Field Summary
static int PARAM_LINEAR_SLOPE
          The offset to the parameter that holds the linear slope.
 
Constructor Summary
ActivationLinear()
          Construct a linear activation function, with a slope of 1.
 
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.
 String getOpenCLExpression(boolean derivative)
          Returns the OpenCL expression for this activation function.
 String[] getParamNames()
          
 double[] getParams()
          
 double getSlope()
           
 boolean hasDerivative()
           
 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_LINEAR_SLOPE

public static final int PARAM_LINEAR_SLOPE
The offset to the parameter that holds the linear slope.

See Also:
Constant Field Values
Constructor Detail

ActivationLinear

public ActivationLinear()
Construct a linear activation function, with a slope of 1.

Method Detail

clone

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

hasDerivative

public boolean hasDerivative()
Specified by:
hasDerivative in interface ActivationFunction
Returns:
Return true, linear has a 1 derivative.

getSlope

public double getSlope()
Returns:
The slope of the activation 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.