lnsc.pmvf
Class AbstractFunctionalUnit2

java.lang.Object
  |
  +--lnsc.pmvf.AbstractFunctionalUnit2
All Implemented Interfaces:
java.lang.Cloneable, FunctionalUnit, FunctionalUnit2, java.io.Serializable
Direct Known Subclasses:
FastLSTMMemoryBlock, FastLSTMNetwork, FastSingleLayerNeuralNetwork

public abstract class AbstractFunctionalUnit2
extends java.lang.Object
implements FunctionalUnit2

Abstract class containing the basic implementation for the FunctionalUnit2 interface.

In order to implement the FunctionalUnit2 interface, subclasses need the following 4 things:

  1. In the constructor, the fields m_InputCount, m_OutputCount, m_IsDifferentiable, m_IsTwiceDifferentiable, m_ParametersCount, m_IsParametersDifferentiable, and m_IsParametersTwiceDifferentiable must be filled appropriately.
  2. processPattern(double[], boolean, boolean, boolean, boolean) must be implemented and should prefrerably begin by calling preProcessPattern(double[], boolean, boolean, boolean, boolean). For non stateless function, reset() must be added.
  3. If the function is parametric (i.e. has more than one parameters), functions getParameters() and setParameters(double[]) must be written accordingly. Note that get and set parameters must work by copying values, not referencing to whole arrays.
  4. Since FunctionalUnit2 are Serializable and Cloneable, any required extra code to make these interfaces work properly should be added. It is necessary to at least set the private static serialVersionUID variable appropriately for the Seriablizable interface. For complex objects, the Cloneable interface can rely on Tools.copyObject(Serializable) for deep cloning.

Since:
1.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class lnsc.pmvf.FunctionalUnit2
FunctionalUnit2.ProcessPatternResult2
 
Nested classes inherited from class lnsc.FunctionalUnit
FunctionalUnit.ProcessPatternResult
 
Field Summary
 
Fields inherited from interface lnsc.FunctionalUnit
EMPTY_PATTERN
 
Constructor Summary
AbstractFunctionalUnit2()
           
 
Method Summary
 java.lang.Object clone()
           
 int getInputCount()
          Indicates the number of variables of the function.
 int getOutputCount()
          Indicates the number of values returned by the function.
 int getParameterCount()
          Indicates the number of parameters of the function.
 boolean isDifferentiable()
          Indicates whether or not the function is differentiable.
 boolean isParameterDifferentiable()
          Indicates whether or not the function is differentiable with respect to its parameters.
 boolean isParameterTwiceDifferentiable()
          Indicates whether or not the function is twice differentiable with respect to its parameters.
 boolean isStateless()
          Indicates whether or not the function output depends solely of the current input (and not of the previous pattern it has processed).
 boolean isTwiceDifferentiable()
          Indicates whether or not the function is twice differentiable.
 DataSet processDataSet(DataSet dataSet, java.lang.String[] recordList)
          Processes a set of input patterns and record the requested information.
 FunctionalUnit.ProcessPatternResult processPattern(double[] inputPattern, boolean computeDerivative, boolean computeSecondDerivative)
          Processes an input pattern and returns its output pattern and derivative (if requested).
 FunctionalUnit2.ProcessPatternResult2 processPattern(double[] inputPattern, boolean computeDerivative, boolean computeSecondDerivative, boolean computeParameterDerivative, boolean computeParameterSecondDerivative, java.lang.String[] recordList)
          Processes an input pattern and returns its output pattern and derivatives (if requested).
 void reset()
          Reset internal transient state for non stateless functions.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface lnsc.pmvf.FunctionalUnit2
getParameters, setParameters
 

Constructor Detail

AbstractFunctionalUnit2

public AbstractFunctionalUnit2()
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface FunctionalUnit
Overrides:
clone in class java.lang.Object
java.lang.CloneNotSupportedException

getInputCount

public final int getInputCount()
Description copied from interface: FunctionalUnit
Indicates the number of variables of the function.

Specified by:
getInputCount in interface FunctionalUnit
Returns:
Number of inputs.

getOutputCount

public final int getOutputCount()
Description copied from interface: FunctionalUnit
Indicates the number of values returned by the function.

Specified by:
getOutputCount in interface FunctionalUnit
Returns:
Number of outputs.

getParameterCount

public final int getParameterCount()
Description copied from interface: FunctionalUnit2
Indicates the number of parameters of the function.

Specified by:
getParameterCount in interface FunctionalUnit2
Returns:
Number of parameters.

isDifferentiable

public final boolean isDifferentiable()
Description copied from interface: FunctionalUnit
Indicates whether or not the function is differentiable.

Specified by:
isDifferentiable in interface FunctionalUnit
Returns:
true if it differentiable, false otherwise.

isParameterDifferentiable

public final boolean isParameterDifferentiable()
Description copied from interface: FunctionalUnit2
Indicates whether or not the function is differentiable with respect to its parameters.

Specified by:
isParameterDifferentiable in interface FunctionalUnit2
Returns:
true if it differentiable, false otherwise.

isParameterTwiceDifferentiable

public final boolean isParameterTwiceDifferentiable()
Description copied from interface: FunctionalUnit2
Indicates whether or not the function is twice differentiable with respect to its parameters.

Specified by:
isParameterTwiceDifferentiable in interface FunctionalUnit2
Returns:
true if it twice differentiable, false otherwise.

isStateless

public final boolean isStateless()
Description copied from interface: FunctionalUnit
Indicates whether or not the function output depends solely of the current input (and not of the previous pattern it has processed). (Any such internal state use for next computation should be in transient variables and not being serialized. They should be reseted on reset.)

Specified by:
isStateless in interface FunctionalUnit
Returns:
true if output depends solely on current input false otherwise.

isTwiceDifferentiable

public final boolean isTwiceDifferentiable()
Description copied from interface: FunctionalUnit
Indicates whether or not the function is twice differentiable.

Specified by:
isTwiceDifferentiable in interface FunctionalUnit
Returns:
true if it twice differentiable, false otherwise.

processDataSet

public DataSet processDataSet(DataSet dataSet,
                              java.lang.String[] recordList)
Description copied from interface: FunctionalUnit
Processes a set of input patterns and record the requested information. To get the derivatives for each pattern, use the keyword DataNames.DERIVATIVES, for the second derivatives use DataNames.SECOND_DERIVATIVES and for the error patterns, use DataNames.ERROR_PATTERNS. Derivatives are available only when the function is differentiable. Error patterns required DataNames.TARGET_PATTERNS to be in the provided data set.

Specified by:
processDataSet in interface FunctionalUnit
Returns:
The given data set augmented with the DataNames.OUTPUT_PATTERNS and any other keywords supported requested. Each FunctionalUnit may provide extra keywords of its own.
See Also:
DataNames

processPattern

public FunctionalUnit.ProcessPatternResult processPattern(double[] inputPattern,
                                                          boolean computeDerivative,
                                                          boolean computeSecondDerivative)
Description copied from interface: FunctionalUnit
Processes an input pattern and returns its output pattern and derivative (if requested).

Specified by:
processPattern in interface FunctionalUnit
Returns:
The output pattern and the derivative (if requested).

processPattern

public FunctionalUnit2.ProcessPatternResult2 processPattern(double[] inputPattern,
                                                            boolean computeDerivative,
                                                            boolean computeSecondDerivative,
                                                            boolean computeParameterDerivative,
                                                            boolean computeParameterSecondDerivative,
                                                            java.lang.String[] recordList)
Description copied from interface: FunctionalUnit2
Processes an input pattern and returns its output pattern and derivatives (if requested).

Specified by:
processPattern in interface FunctionalUnit2
Parameters:
inputPattern - The input pattern.
computeDerivative - Must be true if the derivative should be computed.
computeSecondDerivative - Must be true if the second derivative should be computed.
computeParameterDerivative - Must be true if the derivative with respect to the parameters should be computed.
computeParameterSecondDerivative - Must be true if be the derivative with respect to the parameters should be computed.
recordList - Extra data to be recorded.
Returns:
The output pattern and the derivative (if requested).

reset

public void reset()
Description copied from interface: FunctionalUnit
Reset internal transient state for non stateless functions.

Specified by:
reset in interface FunctionalUnit

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object