All Packages Class Hierarchy This Package Previous Next Index
Class sim.funApp.Net
java.lang.Object
|
+----sim.funApp.FunApp
|
+----sim.funApp.Net
- public class Net
- extends FunApp
Net is a general Neural Network architecture which computes the first and second
derivitives wrt the weights and inputs. The structure is specified using keywords
which describe the weighting scheme from one layer to the next and the activation
function used within a layer. When necessary a number of nodes is also specified in
parenthesis following the activation function keyword. To use Net you should use the
following when a FunApp is required: Net {a w a(#) w a(#) w a(#) w a}
'a' is chosen from the following set of activation functions, {Identity,
HardlimitingSquashing, Bipolar, Monopolar, ExponentialInverted, HyperbolicTan, Sin, Gaussian}.
'w' is chosen from the following set of weighting schemes, {Linear, Quadratic1, Quadratic2}.
'#' stands for number of nodes in that layer. Note that activation functions
must be in the first and last positions and these two actiavtion functions should not
specifiy a number of nodes because that information is given in the Data object.
Original MLP was written by Mance E. Harmon and has been enhanced by Scott Weaver
This code is (c) 1997 Scott E. Weaver
<scott.weaver@uc.edu>,
http://http://www.ececs.uc.edu/~sweaver
The source and object code may be redistributed freely provided
no fee is charged. If the code is modified, please state so
in the comments.
- Version:
- 1.01, 10 Jun 97 added Quadratic2 for SISO RBFs (Bug in FindHessian for Quadratic2)
Becuase this code is so convoluted that the results should and can and should be easily
checked using Mathematica to take the first and second derivitives of the error wrt the
weights and the inputs. Places where the code may be inefficient I've noted with SLOW.
The variables have a specific convention. dSikdwik means derivative of the single node Sik
with respect to the vector wik. The derivitive of this variable with respect to Simo would
be dSikdwikdSimo. imo means the i minus one'th layer. ik means the ith layer and the kth node
in layer i. A variable that ends in T stands for Transpose. 'u' refers to weights in all
layers following (but not including) the current layer. 'w' refers to weights in the current
layer. Variables of the form d?*
stands for derrivitive of ? wrt *, where ? and * are usually variables defined elsewhere
Comments with a number such as (4) or 5 or |2| refer to my personal notes - Scott Weaver
The folowing variables are used so frequently that have been shortened in varios places
prev=nN[i-1].val is Number of nodes in previous layer
curr=nN[i].val is Number of nodes in current layer
- Author:
- Scott Weaver, Leemon Baird
-
Net()
-
-
BNF(int)
- Return the BNF description of how to parse the parameters of this object.
-
clone()
- Make an exact duplicate of this class.
-
cloneVars(FunApp)
- After making a copy of self during a clone(), call cloneVars() to
copy variables into the copy, then return super.cloneVars(copy).
-
evaluate()
- calculate the output for the given input.
-
findGradients()
- Calculate the output, gradient, for a given input.
-
findHessian()
- Calculate the output, gradient, and Hessian for a given input.
-
nWeights(int, int)
- Return # weights needed for nIn inputs (including the first
one which is always 1.0), and nOut outputs.
-
parse(Parser, int)
- Parse the input file to get the parameters for this object.
-
setIO(MatrixD, MatrixD, MatrixD, MatrixD, MatrixD, MatrixD, MatrixD, MatrixD, MatrixD)
- Define the MatrixD objects that will be used by evaluate()
and findGradients().
-
unparse(Unparser, int)
- Output a description of this object that can be parsed with parse().
Net
public Net()
setIO
public void setIO(MatrixD inVect,
MatrixD outVect,
MatrixD weights,
MatrixD dEdIn,
MatrixD dEdOut,
MatrixD dEdWeights,
MatrixD dEdIndIn,
MatrixD dEdOutdOut,
MatrixD dEdWeightsdWeights) throws MatrixException
- Define the MatrixD objects that will be used by evaluate()
and findGradients(). All 9 should be column vectors (n by 1 matrices).
All the MatrixD objects are copied, but the pointers still point
to the same data arrays.
- Throws: MatrixException
- if vector shapes don't match
- Overrides:
- setIO in class FunApp
evaluate
public void evaluate()
- calculate the output for the given input. Also calculates Ap and App because
it is appropriate to do so eventhough they are not used until backward pass
- Overrides:
- evaluate in class FunApp
findGradients
public void findGradients()
- Calculate the output, gradient, for a given input.
This does everything evaluate() does, plus
it calculates the Gradient of the error with resepect to the
the weights and inputs, dEdx, and dEdw.
User must set dEdOut and dEdOut before calling.
- Overrides:
- findGradients in class FunApp
findHessian
public void findHessian()
- Calculate the output, gradient, and Hessian for a given input.
This does everything evaluate() and findGradients() do, plus
it calculates the Hessian of the error with resepect to the
the weights and inputs, dEdxdx, dEdwdx, and dEdwdw.
User must set dEdOut and dEdOutdOut before calling.
- Overrides:
- findHessian in class FunApp
nWeights
public int nWeights(int nIn,
int nOut)
- Return # weights needed for nIn inputs (including the first
one which is always 1.0), and nOut outputs.
- Overrides:
- nWeights in class FunApp
BNF
public String BNF(int lang)
- Return the BNF description of how to parse the parameters of this object.
- Overrides:
- BNF in class FunApp
unparse
public void unparse(Unparser u,
int lang)
- Output a description of this object that can be parsed with parse().
- Overrides:
- unparse in class FunApp
- See Also:
- Parsable
parse
public Object parse(Parser p,
int lang) throws ParserException
- Parse the input file to get the parameters for this object.
- Throws: ParserException
- parser didn't find the required token
- Overrides:
- parse in class FunApp
clone
public Object clone()
- Make an exact duplicate of this class. For objects it contains, it
only duplicates the pointers, not the objects they point to. For a
new FunApp called MyFunApp, the code in this method should be the
single line: return cloneVars(new MyFunApp());
- Overrides:
- clone in class FunApp
cloneVars
public Object cloneVars(FunApp copy)
- After making a copy of self during a clone(), call cloneVars() to
copy variables into the copy, then return super.cloneVars(copy).
The variables copied are just those set in parse() and
setWatchManager(). The caller will be required to call
setIO to set up the rest of the variables.
- Overrides:
- cloneVars in class FunApp
All Packages Class Hierarchy This Package Previous Next Index