All Packages Class Hierarchy This Package Previous Next Index
Class sim.funApp.FunApp
java.lang.Object
|
+----sim.funApp.FunApp
- public abstract class FunApp
- extends Object
- implements Parsable, Watchable
All function approximators should inherit from FunApp.
A function approximator should store its parameters in the array weights[].
The gradient functions are used for various gradient-descent algorithms.
The store functions are used for various memory-based learning algorithms.
This code is (c) 1996 Leemon Baird
<leemon@cs.cmu.edu>,
http://www.cs.cmu.edu/~baird
The source and object code may be redistributed freely.
If the code is modified, please state so in the comments.
- Version:
- 1.01, 31 October 96
- Author:
- Leemon Baird
-
dEdIn
- a vector for the gradient of error with respect to the inputs
-
dEdOut
- a vector for the gradient of error with respect to the output
-
dEdWeights
- a vector for the gradient of error with respect to the weights
-
inVect
- clone of the input, should be a vector with first element 1.0
-
outVect
- clone of the output, should be a vector
-
pInput
-
-
pOutput
-
-
pWeights
-
-
watchManager
- the WatchManager that variables here may be registered with
-
weights
- clone of a vector for the adjustable parameters of the function approximator
-
wmName
- the prefix string for the name of every watched variable (passed in to setWatchManager)
-
FunApp()
-
-
BNF(int)
-
-
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).
-
destroy()
- This is called when the object is destroyed.
-
evaluate()
- Calculate the output for the given input
-
findGradients()
- Calculate the output and gradient for a given input.
-
findHessian()
- Calculate the output, gradient, and Hessian for a given input.
-
getInput()
- return the input vector (including one element that's always 1.0)
that was set by setIO.
-
getName()
- Return the variable "name" that was passed into setWatchManager.
-
getOutput()
- return the output vector that was set by setIO
-
getParameters(int)
- Return a parameter array if BNF(), parse(), and unparse() are to be automated, null otherwise.
-
getWatchManager()
- Return the WatchManager set by setWatchManager().
-
getWeights()
- return the weight vector that was set by setIO
-
initialize(int)
- Initialize, either partially or completely.
-
learn(double[], double[])
- store this new input/output pair as a data point for memory-based learning
-
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(), findGradients(),
and findHessian().
-
setWatchManager(WatchManager, String)
- Register all variables with this WatchManager.
-
unparse(Unparser, int)
- Output a description of this object that can be parsed with parse().
inVect
protected MatrixD inVect
- clone of the input, should be a vector with first element 1.0
outVect
protected MatrixD outVect
- clone of the output, should be a vector
weights
protected MatrixD weights
- clone of a vector for the adjustable parameters of the function approximator
dEdOut
protected MatrixD dEdOut
- a vector for the gradient of error with respect to the output
dEdWeights
protected MatrixD dEdWeights
- a vector for the gradient of error with respect to the weights
dEdIn
protected MatrixD dEdIn
- a vector for the gradient of error with respect to the inputs
watchManager
protected WatchManager watchManager
- the WatchManager that variables here may be registered with
wmName
protected String wmName
- the prefix string for the name of every watched variable (passed in to setWatchManager)
pInput
protected PMatrixD pInput
pOutput
protected PMatrixD pOutput
pWeights
protected PMatrixD pWeights
FunApp
public FunApp()
setWatchManager
public void setWatchManager(WatchManager wm,
String name)
- Register all variables with this WatchManager.
Any function approximator overriding this should first
call super.setWatchManager() for the important housekeeping done.
getName
public String getName()
- Return the variable "name" that was passed into setWatchManager.
This name is the prefix of the names of all watchable variables
within this object
getWatchManager
public WatchManager getWatchManager()
- Return the WatchManager set by setWatchManager().
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(), findGradients(),
and findHessian(). First 6 should be column vectors (n by 1 matrices).
The last 3 parameters can be null if the Hessian is never to be calculated.
If a function approximator overrides this, it should first call
super.setIO() for important housekeeping.
- Throws: MatrixException
- if inputs are vectors with nonmatching sizes
getInput
public final MatrixD getInput()
- return the input vector (including one element that's always 1.0)
that was set by setIO.
getOutput
public final MatrixD getOutput()
- return the output vector that was set by setIO
getWeights
public final MatrixD getWeights()
- return the weight vector that was set by setIO
learn
public void learn(double in[],
double out[])
- store this new input/output pair as a data point for memory-based learning
evaluate
public abstract void evaluate()
- Calculate the output for the given input
findGradients
public abstract void findGradients()
- Calculate the output and gradient for a given input.
This does everything evaluate() does, plus it calculates
the gradient of the error with respect to the inputs and
weights, dEdx and dEdw,
User must set dEdOut before calling.
findHessian
public abstract 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
User must set dEdOut and dEdOutdOut before calling.
nWeights
public abstract int nWeights(int nIn,
int nOut)
- Return # weights needed for nIn inputs (including the first
one which is always 1.0), and nOut outputs.
getParameters
public Object[][] getParameters(int lang)
- Return a parameter array if BNF(), parse(), and unparse() are to be automated, null otherwise.
- See Also:
- getParameters
BNF
public abstract String BNF(int lang)
unparse
public abstract void unparse(Unparser u,
int lang)
- Output a description of this object that can be parsed with parse().
- See Also:
- Parsable
parse
public abstract 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
destroy
public void destroy()
- This is called when the object is destroyed. Override it
to react to that event (e.g. kill threads, dispose of Graphics)
clone
public abstract 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 Object
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.
initialize
public void initialize(int level)
- Initialize, either partially or completely.
- See Also:
- initialize
All Packages Class Hierarchy This Package Previous Next Index