|
JMSLTM Numerical Library 5.0.1 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.imsl.datamining.neural.Network
com.imsl.datamining.neural.FeedForwardNetwork
public class FeedForwardNetwork
A representation of a feed forward neural network.
A Network contains an InputLayer, an
OutputLayer and zero or more HiddenLayers. The
null InputLayer and OutputLayer are
automatically created by the Network constructor. The
InputNodes are added using the
getInputLayer().createInputs(nInputs) method. Output Perceptrons
are added using the getOutputLayer().createPerceptrons(nOutputs), and HiddenLayers
can be created using the createHiddenLayer().createPerceptrons(nPerceptrons) method.
The InputLayer contains InputNodes. The
HiddenLayers and OutputLayers contain
Perceptron nodes. These Nodes are created
using factory methods in the Layers.
The Network also contains Links between
Nodes. Links are created by methods in this class.
Each Link has a weight and gradient value.
Each Perceptron node has a bias value. When the
Network is trained, the weight and bias values are
used as initial guesses. After the Network is trained the
weight, gradient and bias values are
set to the values computed by the training.
A feed forward network is a network in which links are only allowed from one layer to a following layer.
| Constructor Summary | |
|---|---|
FeedForwardNetwork()
Creates a new instance of FeedForwardNetwork. |
|
| Method Summary | |
|---|---|
HiddenLayer |
createHiddenLayer()
Creates a HiddenLayer. |
Link |
findLink(Node from,
Node to)
Returns the Link between two Nodes. |
Link[] |
findLinks(Node to)
Returns all of the Links to a given Node. |
double[] |
forecast(double[] x)
Computes a forecast using the Network. |
double[][] |
getForecastGradient(double[] xData)
Returns the derivatives of the outputs with respect to the weights. |
HiddenLayer[] |
getHiddenLayers()
Returns the HiddenLayers in this network. |
InputLayer |
getInputLayer()
Returns the InputLayer. |
Link[] |
getLinks()
Return all of the Links in this Network. |
int |
getNumberOfInputs()
Returns the number of inputs to the Network. |
int |
getNumberOfLinks()
Returns the number of Links in the Network. |
int |
getNumberOfOutputs()
Returns the number of outputs from the Network. |
int |
getNumberOfWeights()
Returns the number of weights in the Network. |
OutputLayer |
getOutputLayer()
Returns the OutputLayer. |
Perceptron[] |
getPerceptrons()
Returns the Perceptrons in this Network. |
double[] |
getWeights()
Returns the weights for the Links in this network. |
Link |
link(Node from,
Node to)
Establishes a Link between two Nodes. |
Link |
link(Node from,
Node to,
double weight)
Establishes a Link between two Nodes with a
specified weight. |
void |
linkAll()
For each Layer in the Network, link each
Node in the Layer to each Node
in the next Layer. |
void |
linkAll(Layer from,
Layer to)
Link all of the Nodes in one Layer to all of
the Nodes in another Layer. |
void |
remove(Link link)
Removes a Link from the network. |
void |
setEqualWeights(double[][] xData)
Initializes network weights using equal weighting. |
void |
setRandomWeights(double[][] xData,
Random random)
Initializes network weights using random weights. |
void |
setWeights(double[] weights)
Sets the weights for the Links in this
Network. |
protected void |
validateLink(Node from,
Node to)
Checks that a Link between two Nodes is valid. |
| Methods inherited from class com.imsl.datamining.neural.Network |
|---|
computeStatistics |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FeedForwardNetwork()
FeedForwardNetwork.
| Method Detail |
|---|
public HiddenLayer createHiddenLayer()
HiddenLayer.
createHiddenLayer in class NetworkHiddenLayer object which specifies a neural
network hidden layer.
public Link findLink(Node from,
Node to)
Link between two Nodes.
from - The origination Node.to - The destination Node.
Link between the two Nodes, or
null if no such Link exists.public Link[] findLinks(Node to)
Links to a given Node.
to - A Node who's Links are to be
determined.
Links containing all of the
Links to the given Node.public double[] forecast(double[] x)
Network.
forecast in class Networkx - A double array of values to which the
Nodes in the InputLayer are to be set.
double array containing the values of the
Nodes in the OutputLayer.public double[][] getForecastGradient(double[] xData)
getForecastGradient in class NetworkxData - A double array which specifies the input
values at which the gradient is to be evaluated.
double array containing the gradient values.
The value of gradient[i][j] is
public HiddenLayer[] getHiddenLayers()
HiddenLayers in this network.
HiddenLayers in this network.public InputLayer getInputLayer()
InputLayer.
getInputLayer in class NetworkInputLayer.public Link[] getLinks()
Links in this Network.
getLinks in class NetworkLinks containing all of the
Links in this Network.public int getNumberOfInputs()
Network.
getNumberOfInputs in class Networkint containing the number of inputs to the
Network.public int getNumberOfLinks()
Links in the Network.
getNumberOfLinks in class Networkint which contains the number of
Links in the Network.public int getNumberOfOutputs()
Network.
getNumberOfOutputs in class Networkint containing the number of outputs from the
Network.public int getNumberOfWeights()
Network.
getNumberOfWeights in class Networkint which contains the number of weights
in the Network.public OutputLayer getOutputLayer()
OutputLayer.
getOutputLayer in class NetworkOutputLayer.public Perceptron[] getPerceptrons()
Perceptrons in this Network.
getPerceptrons in class NetworkPerceptrons in this network.public double[] getWeights()
Links in this network.
getWeights in class Networkdoubles containing the weights.
The array contains the weights for each Link
followed by the Perceptron bias values. The
Link weights are in the order in which the
Links were created. The weight values are
first, followed by the bias values in the
HiddenLayers and then the bias values in the
OutputLayer, and then by the order in which the
Perceptrons were created.
public Link link(Node from,
Node to)
Link between two Nodes. Any
existing Link between these Nodes is removed.
from - The origination Node.to - The destination Node.
Link between the two Nodes.
public Link link(Node from,
Node to,
double weight)
Link between two Nodes with a
specified weight.
from - The origination Node.to - The destination Node.weight - A double which specifies the weight
to be given the Link.
Link between the two Nodes.public void linkAll()
Layer in the Network, link each
Node in the Layer to each Node
in the next Layer.
public void linkAll(Layer from,
Layer to)
Nodes in one Layer to all of
the Nodes in another Layer.
from - The origination Layer.to - The destination Layer.public void remove(Link link)
Link from the network.
link - The Link deleted from the network.public void setEqualWeights(double[][] xData)
The equal weights approach starts by assigning equal values to the
inputs of each Perceptron. If a Perceptron
has 4 inputs, then this method starts by assigning the value 1/4 to each
of the perceptron's input weights. The bias
weight is initially assigned a value of zero.
The weights for the first Layer of Perceptrons,
either the first HiddenLayer if the number of Layers
is greater than 1 or the OutputLayer, are scaled using the
training patterns. Scaling is accomplished by dividing the initial
weights for the first Layer by the standard deviation,
s, of the potential for that Perceptron. The bias
weight is set to -avg/s, where avg is the average potential
for that Perceptron. This makes the average potential for
the Perceptrons in this first Layer approximately
0 and its standard deviation equal to 1.
This reduces the possibility of saturation during network training
resulting from very large or small values for the Perceptron's
potential. During training random noise is added to these intial values
at each training stage. If the EpochTrainer is used, noise
is added to these initial values at the start of each epoch.
xData - An input double matrix containing training patterns.
The number of columns in xData must equal the
number of Perceptrons in the InputLayer.
public void setRandomWeights(double[][] xData,
Random random)
The RandomWeights algorithm assigns equal weights to all
Perceptrons, except those in the first Layer
connected to the InputLayer. Like the EqualWeights
algorithm, Perceptrons not in the first Layer
are assigned weights 1/k, where k is the number of
inputs connected to that Perceptron.
For the first Layer Perceptron weights, they are
initially assigned values from the uniform random distribution on the
interval [-0.5, +0.5]. These are then scaled using the training patterns.
The random weights for a Perceptron are divided by
s, the standard deviation of the potential for that
Perceptron calculated using the intial random values.
Its bias value is set to -avg/s, where avg is the
average potential for that PerceptronPerceptrons in this first Layer
approximately 0 and its standard deviation equal to 1.
This reduces the possibility of saturation during network training
resulting from very large or small values for the Perceptron's
potential. During training random noise is added to these intial values
at each training stage. If the EpochTrainer is used, noise
is added to these initial values at the start of each epoch.
xData - An input double matrix containing training patterns.
The number of columns in xData
must equal the number of Perceptrons in the
InputLayer.random - A Random object.public void setWeights(double[] weights)
Links in this
Network.
setWeights in class Networkweights - A double array containing the weights
in the same order as getWeights().
protected void validateLink(Node from,
Node to)
throws IllegalArgumentException
Link between two Nodes is valid.
In a FeedForwardNetwork a Link must be from
a node in one Layer to a Node in a later
Layer. Intermediate Layers can be skipped, but
a Link cannot go backward.
from - The origination Node.to - The destination Node.
IllegalArgumentException - is thrown if the Link
is not valid
|
JMSLTM Numerical Library 5.0.1 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||