|
JMSLTM Numerical Library 5.0.1 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.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 HiddenLayer
s. The
null
InputLayer
and OutputLayer
are
automatically created by the Network
constructor. The
InputNode
s are added using the
getInputLayer().createInputs(nInputs)
method. Output Perceptron
s
are added using the getOutputLayer().createPerceptrons(nOutputs)
, and HiddenLayer
s
can be created using the createHiddenLayer().createPerceptrons(nPerceptrons)
method.
The InputLayer
contains InputNode
s. The
HiddenLayer
s and OutputLayers
contain
Perceptron
nodes. These Node
s are created
using factory methods in the Layer
s.
The Network
also contains Link
s between
Node
s. Link
s 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 Node s. |
Link[] |
findLinks(Node to)
Returns all of the Link s 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 HiddenLayer s in this network. |
InputLayer |
getInputLayer()
Returns the InputLayer . |
Link[] |
getLinks()
Return all of the Link s in this Network . |
int |
getNumberOfInputs()
Returns the number of inputs to the Network . |
int |
getNumberOfLinks()
Returns the number of Link s 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 Perceptron s in this Network . |
double[] |
getWeights()
Returns the weights for the Link s in this network. |
Link |
link(Node from,
Node to)
Establishes a Link between two Node s. |
Link |
link(Node from,
Node to,
double weight)
Establishes a Link between two Node s 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 Node s in one Layer to all of
the Node s 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 Link s in this
Network . |
protected void |
validateLink(Node from,
Node to)
Checks that a Link between two Node s 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 Network
HiddenLayer
object which specifies a neural
network hidden layer.public Link findLink(Node from, Node to)
Link
between two Node
s.
from
- The origination Node
.to
- The destination Node
.
Link
between the two Node
s, or
null
if no such Link
exists.public Link[] findLinks(Node to)
Link
s to a given Node
.
to
- A Node
who's Link
s are to be
determined.
Link
s containing all of the
Link
s to the given Node
.public double[] forecast(double[] x)
Network
.
forecast
in class Network
x
- A double
array of values to which the
Node
s in the InputLayer
are to be set.
double
array containing the values of the
Node
s in the OutputLayer
.public double[][] getForecastGradient(double[] xData)
getForecastGradient
in class Network
xData
- 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
, where
is the i-th output and
is the j-th weight.public HiddenLayer[] getHiddenLayers()
HiddenLayer
s in this network.
HiddenLayer
s in this network.public InputLayer getInputLayer()
InputLayer
.
getInputLayer
in class Network
InputLayer
.public Link[] getLinks()
Link
s in this Network
.
getLinks
in class Network
Link
s containing all of the
Link
s in this Network
.public int getNumberOfInputs()
Network
.
getNumberOfInputs
in class Network
int
containing the number of inputs to the
Network
.public int getNumberOfLinks()
Link
s in the Network
.
getNumberOfLinks
in class Network
int
which contains the number of
Link
s in the Network
.public int getNumberOfOutputs()
Network
.
getNumberOfOutputs
in class Network
int
containing the number of outputs from the
Network
.public int getNumberOfWeights()
Network
.
getNumberOfWeights
in class Network
int
which contains the number of weights
in the Network
.public OutputLayer getOutputLayer()
OutputLayer
.
getOutputLayer
in class Network
OutputLayer
.public Perceptron[] getPerceptrons()
Perceptron
s in this Network
.
getPerceptrons
in class Network
Perceptron
s in this network.public double[] getWeights()
Link
s in this network.
getWeights
in class Network
double
s 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
Perceptron
s were created.public Link link(Node from, Node to)
Link
between two Node
s. Any
existing Link
between these Node
s is removed.
from
- The origination Node
.to
- The destination Node
.
Link
between the two Node
s.public Link link(Node from, Node to, double weight)
Link
between two Node
s 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 Node
s.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)
Node
s in one Layer
to all of
the Node
s 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 Layer
s
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 Perceptron
s 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 Perceptron
s in the InputLayer
.public void setRandomWeights(double[][] xData, Random random)
The RandomWeights
algorithm assigns equal weights to all
Perceptron
s, except those in the first Layer
connected to the InputLayer
. Like the EqualWeights
algorithm, Perceptron
s 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 PerceptronPerceptron
s 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)
Link
s in this
Network
.
setWeights
in class Network
weights
- A double
array containing the weights
in the same order as getWeights()
.protected void validateLink(Node from, Node to) throws IllegalArgumentException
Link
between two Node
s is valid.
In a FeedForwardNetwork
a Link
must be from
a node in one Layer
to a Node
in a later
Layer
. Intermediate Layer
s 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 |