gov.sandia.cognition.learning.function.vector
Class DifferentiableFeedforwardNeuralNetwork

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.vector.FeedforwardNeuralNetwork
          extended by gov.sandia.cognition.learning.function.vector.DifferentiableFeedforwardNeuralNetwork
All Implemented Interfaces:
Evaluator<Vector,Vector>, GradientDescendable, ParameterGradientEvaluator<Vector,Matrix>, VectorFunction, Vectorizable, VectorizableVectorFunction, CloneableSerializable, Serializable, Cloneable

public class DifferentiableFeedforwardNeuralNetwork
extends FeedforwardNeuralNetwork
implements GradientDescendable

A feedforward neural network that can have an arbitrary number of layers, and an arbitrary differentiable squashing (activation) function assigned to each layer. The squashing functions must be differentiable.

Since:
1.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Constructor Summary
DifferentiableFeedforwardNeuralNetwork(ArrayList<Integer> nodesPerLayer, ArrayList<DifferentiableUnivariateScalarFunction> layerActivationFunctions, Random random)
          Creates a new instance of DifferentiableFeedforwardNeuralNetwork
DifferentiableFeedforwardNeuralNetwork(DifferentiableGeneralizedLinearModel... layers)
          Creates a new instance of FeedforwardNeuralNetwork
DifferentiableFeedforwardNeuralNetwork(int numInputs, int numHiddens, int numOutputs, DifferentiableUnivariateScalarFunction scalarFunction, Random random)
          Creates a new instance of FeedforwardNeuralNetwork
DifferentiableFeedforwardNeuralNetwork(int numInputs, int numHiddens, int numOutputs, DifferentiableVectorFunction activationFunction, Random random)
          Creates a new instance of FeedforwardNeuralNetwork
 
Method Summary
 DifferentiableFeedforwardNeuralNetwork clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 Matrix computeParameterGradient(Vector input)
          Computes the derivative of the function about the input with respect to the parameters of the function
 ArrayList<DifferentiableGeneralizedLinearModel> getLayers()
          Getter for layers
 
Methods inherited from class gov.sandia.cognition.learning.function.vector.FeedforwardNeuralNetwork
convertFromVector, convertToVector, evaluate, evaluateAtEachLayer, setLayers, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.evaluator.Evaluator
evaluate
 
Methods inherited from interface gov.sandia.cognition.math.matrix.Vectorizable
convertFromVector, convertToVector
 

Constructor Detail

DifferentiableFeedforwardNeuralNetwork

public DifferentiableFeedforwardNeuralNetwork(ArrayList<Integer> nodesPerLayer,
                                              ArrayList<DifferentiableUnivariateScalarFunction> layerActivationFunctions,
                                              Random random)
Creates a new instance of DifferentiableFeedforwardNeuralNetwork

Parameters:
nodesPerLayer - Number of nodes in each layer, must have no fewer than 2 layers
layerActivationFunctions - Squashing function to assign to each layer, must have one fewer squashing function than you do layers (that is, the input layer has no squashing)
random - The random number generator for initial weights.

DifferentiableFeedforwardNeuralNetwork

public DifferentiableFeedforwardNeuralNetwork(int numInputs,
                                              int numHiddens,
                                              int numOutputs,
                                              DifferentiableVectorFunction activationFunction,
                                              Random random)
Creates a new instance of FeedforwardNeuralNetwork

Parameters:
numInputs - Number of nodes in the input layer
numHiddens - Number of nodes in the hidden (middle) layer
numOutputs - Number of nodes in the output layer
activationFunction - Squashing function to assign to all layers
random - The random number generator for the initial weights.

DifferentiableFeedforwardNeuralNetwork

public DifferentiableFeedforwardNeuralNetwork(int numInputs,
                                              int numHiddens,
                                              int numOutputs,
                                              DifferentiableUnivariateScalarFunction scalarFunction,
                                              Random random)
Creates a new instance of FeedforwardNeuralNetwork

Parameters:
numInputs - Number of nodes in the input layer
numHiddens - Number of nodes in the hidden (middle) layer
numOutputs - Number of nodes in the output layer
scalarFunction - Squashing function to assign to all layers
random - The random number generator for the initial weights.

DifferentiableFeedforwardNeuralNetwork

public DifferentiableFeedforwardNeuralNetwork(DifferentiableGeneralizedLinearModel... layers)
Creates a new instance of FeedforwardNeuralNetwork

Parameters:
layers - Layers of the neural network
Method Detail

clone

public DifferentiableFeedforwardNeuralNetwork clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface GradientDescendable
Specified by:
clone in interface Vectorizable
Specified by:
clone in interface VectorizableVectorFunction
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class FeedforwardNeuralNetwork
Returns:
A clone of this object.

getLayers

public ArrayList<DifferentiableGeneralizedLinearModel> getLayers()
Description copied from class: FeedforwardNeuralNetwork
Getter for layers

Overrides:
getLayers in class FeedforwardNeuralNetwork
Returns:
Layers that comprise this neural network

computeParameterGradient

public Matrix computeParameterGradient(Vector input)
Description copied from interface: GradientDescendable
Computes the derivative of the function about the input with respect to the parameters of the function

Specified by:
computeParameterGradient in interface GradientDescendable
Specified by:
computeParameterGradient in interface ParameterGradientEvaluator<Vector,Matrix>
Parameters:
input - Point about which to differentiate w.r.t. the parameters
Returns:
Matrix of parameter gradients