@CodeReview(reviewer="Justin Basilico", date="2006-10-06", changesNeeded=true, comments={"Can you just add a comment for why the differentiation code is correct?","Otherwise, class looks fine."}, response=@CodeReviewResponse(respondent="Kevin R. Dixon",date="2006-10-06",moreChangesNeeded=false,comments="Added in-code comment describing the derivation of the differentiation formulae.")) public class MultivariateDiscriminant extends AbstractCloneableSerializable implements VectorizableDifferentiableVectorFunction, VectorInputEvaluator<Vector,Vector>, VectorOutputEvaluator<Vector,Vector>, GradientDescendable
| Constructor and Description |
|---|
MultivariateDiscriminant()
Default constructor.
|
MultivariateDiscriminant(int numInputs,
int numOutputs)
Creates a new MultivariateDiscriminant
|
MultivariateDiscriminant(Matrix discriminant)
Creates a new instance of MatrixVectorMultiplyFunction.
|
MultivariateDiscriminant(MultivariateDiscriminant other)
Copy constructor
|
| Modifier and Type | Method and Description |
|---|---|
MultivariateDiscriminant |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
static Matrix |
computeParameterGradient(Matrix matrix,
Vector input)
Computes the parameter gradient of the given matrix post-multiplied
by the input Vector
|
Matrix |
computeParameterGradient(Vector input)
Computes the derivative of the function about the input with respect
to the parameters of the function.
|
void |
convertFromVector(Vector parameters)
Uploads a matrix from a row-stacked vector of parameters.
|
Vector |
convertToVector()
Creates a row-stacked version of the discriminant.
|
Matrix |
differentiate(Vector input)
Differentiate the VectorFunction at
input and return
the Jacobian |
Vector |
evaluate(Vector input)
Evaluates the function on the given input and returns the output.
|
Matrix |
getDiscriminant()
Getter for discriminant.
|
int |
getInputDimensionality()
Gets the expected dimensionality of the input vector to the evaluator,
if it is known.
|
int |
getOutputDimensionality()
Gets the expected dimensionality of the output vector of the evaluator,
if it is known.
|
protected void |
setDiscriminant(Matrix discriminant)
Setter for discriminant
|
java.lang.String |
toString() |
public MultivariateDiscriminant()
public MultivariateDiscriminant(int numInputs,
int numOutputs)
numInputs - Number of inputs of the function (number of matrix columns)numOutputs - Number of outputs of the function (number of matrix rows)public MultivariateDiscriminant(Matrix discriminant)
discriminant - internal matrix to premultiply input vectors by.public MultivariateDiscriminant(MultivariateDiscriminant other)
other - MultivariateDiscriminant to copypublic MultivariateDiscriminant clone()
AbstractCloneableSerializableObject class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone() to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone() as the basis for your implementation.clone in interface GradientDescendableclone in interface Vectorizableclone in interface VectorizableVectorFunctionclone in interface CloneableSerializableclone in class AbstractCloneableSerializablepublic Matrix getDiscriminant()
protected void setDiscriminant(Matrix discriminant)
discriminant - internal matrix to premultiply input vectors bypublic Vector convertToVector()
convertToVector in interface Vectorizablepublic void convertFromVector(Vector parameters)
convertFromVector in interface Vectorizableparameters - row-stacked version of discriminantpublic Vector evaluate(Vector input)
Evaluatorpublic Matrix differentiate(Vector input)
DifferentiableVectorFunctioninput and return
the Jacobiandifferentiate in interface DifferentiableEvaluator<Vector,Vector,Matrix>differentiate in interface DifferentiableVectorFunctioninput - Vector input to the VectorFunction, about which to evaluate
the VectorFunctioninputpublic Matrix computeParameterGradient(Vector input)
GradientDescendablecomputeParameterGradient in interface GradientDescendablecomputeParameterGradient in interface ParameterGradientEvaluator<Vector,Vector,Matrix>input - Point about which to differentiate w.r.t. the parameters.public static Matrix computeParameterGradient(Matrix matrix, Vector input)
matrix - Matrix to pre-multiply the input Vector.input - Vector to post-multiply the Matrix.public java.lang.String toString()
toString in class java.lang.Objectpublic int getInputDimensionality()
VectorInputEvaluatorgetInputDimensionality in interface VectorInputEvaluator<Vector,Vector>public int getOutputDimensionality()
VectorOutputEvaluatorgetOutputDimensionality in interface VectorOutputEvaluator<Vector,Vector>