org.encog.engine.network.activation
Class ActivationCompetitive

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

public class ActivationCompetitive
extends Object
implements ActivationFunction

An activation function that only allows a specified number, usually one, of the out-bound connection to win. These connections will share in the sum of the output, whereas the other neurons will receive zero. This activation function can be useful for "winner take all" layers.

See Also:
Serialized Form

Field Summary
static int PARAM_COMPETITIVE_MAX_WINNERS
          The offset to the parameter that holds the max winners.
 
Constructor Summary
ActivationCompetitive()
          Create a competitive activation function with one winner allowed.
ActivationCompetitive(int winners)
          Create a competitive activation function with the specified maximum number of winners.
 
Method Summary
 void activationFunction(double[] x, int start, int size)
          Implements the activation function.
 ActivationFunction clone()
           
 double derivativeFunction(double d)
          Implements the activation function.
 int getMaxWinners()
           
 String getOpenCLExpression(boolean derivative)
          Returns the OpenCL expression for this activation function.
 String[] getParamNames()
          
 double[] getParams()
          
 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_COMPETITIVE_MAX_WINNERS

public static final int PARAM_COMPETITIVE_MAX_WINNERS
The offset to the parameter that holds the max winners.

See Also:
Constant Field Values
Constructor Detail

ActivationCompetitive

public ActivationCompetitive()
Create a competitive activation function with one winner allowed.


ActivationCompetitive

public ActivationCompetitive(int winners)
Create a competitive activation function with the specified maximum number of winners.

Parameters:
winners - The maximum number of winners that this function supports.
Method Detail

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.

clone

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

derivativeFunction

public double derivativeFunction(double d)
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:
derivativeFunction in interface ActivationFunction
Parameters:
d - The input array to the activation function.
Returns:
The derivative.

getMaxWinners

public int getMaxWinners()
Returns:
The maximum number of winners this function supports.

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.

hasDerivative

public boolean hasDerivative()
Specified by:
hasDerivative in interface ActivationFunction
Returns:
False, indication that no derivative is available for this 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.