|
JMSLTM Numerical Library 4.0 | ||||||||
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
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 hidden layer if the number of layers is greater than 1 or the output layer, 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 epoch trainer 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 nodes in the input layer.public void setRandomWeights(double[][] xData, Random random)
The random weights algorithm assigns equal weights to all perceptrons, except those in the first layer connected to the input layer. Like the equal weights 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 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 epoch trainer 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 nodes in the input layer.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 feed forward network 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 4.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |