@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()
AbstractCloneableSerializable
Object
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 GradientDescendable
clone
in interface Vectorizable
clone
in interface VectorizableVectorFunction
clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public Matrix getDiscriminant()
protected void setDiscriminant(Matrix discriminant)
discriminant
- internal matrix to premultiply input vectors bypublic Vector convertToVector()
convertToVector
in interface Vectorizable
public void convertFromVector(Vector parameters)
convertFromVector
in interface Vectorizable
parameters
- row-stacked version of discriminantpublic Vector evaluate(Vector input)
Evaluator
public Matrix differentiate(Vector input)
DifferentiableVectorFunction
input
and return
the Jacobiandifferentiate
in interface DifferentiableEvaluator<Vector,Vector,Matrix>
differentiate
in interface DifferentiableVectorFunction
input
- Vector input to the VectorFunction, about which to evaluate
the VectorFunctioninput
public Matrix computeParameterGradient(Vector input)
GradientDescendable
computeParameterGradient
in interface GradientDescendable
computeParameterGradient
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.Object
public int getInputDimensionality()
VectorInputEvaluator
getInputDimensionality
in interface VectorInputEvaluator<Vector,Vector>
public int getOutputDimensionality()
VectorOutputEvaluator
getOutputDimensionality
in interface VectorOutputEvaluator<Vector,Vector>