public class WeightedCostApproximator extends java.lang.Object implements LinearApproximator
A LinearApproximator in which error is evaluated at a fixed set of points, and the cost function that is minimized is a weighted integral of squared error.
Uses the Moore-Penrose pseudoinverse.
TODO: testModifier and Type | Class and Description |
---|---|
static class |
WeightedCostApproximator.Factory
An ApproximatorFactory that produces WeightedCostApproximators.
|
Constructor and Description |
---|
WeightedCostApproximator(float[][][] evaluationSignals,
float[][][] values,
Function costFunction,
float noise,
int nSV,
boolean quiet) |
WeightedCostApproximator(float[][] evaluationPoints,
float[][] values,
Function costFunction,
float noise,
int nSV) |
WeightedCostApproximator(float[][] evaluationPoints,
float[][] values,
Function costFunction,
float noise,
int nSV,
boolean quiet) |
Modifier and Type | Method and Description |
---|---|
static boolean |
canUseGPU() |
LinearApproximator |
clone() |
float[] |
findCoefficients(float[] targetSignal)
Similar to findCoefficients(ca.nengo.math.Function), but finds coefficients for a target signal (over time)
rather than a target function.
|
float[] |
findCoefficients(Function target)
This implementation is adapted from Eliasmith & Anderson, 2003, appendix A.
|
float[][] |
getEvalPoints() |
static java.lang.String |
getGPUErrorMessage() |
static boolean |
getUseGPU() |
float[][] |
getValues() |
double[][] |
pseudoInverse(double[][] matrix,
float minSV,
int nSV)
Override this method to use a different pseudoinverse implementation (eg clustered).
|
static void |
setUseGPU(boolean use) |
public WeightedCostApproximator(float[][] evaluationPoints, float[][] values, Function costFunction, float noise, int nSV, boolean quiet)
evaluationPoints
- Points at which error is evaluated (should be uniformly
distributed, as the sum of error at these points is treated as an integral
over the domain of interest). Examples include vector inputs to an ensemble,
or different points in time within different simulation regimes.values
- The values of whatever functions are being combined, at the
evaluationPoints. Commonly neuron firing rates. The first dimension makes up
the list of functions, and the second the values of these functions at each
evaluation point.costFunction
- A cost function that weights squared error over the domain of
evaluation pointsnoise
- Standard deviation of Gaussian noise to add to values (to reduce
sensitivity to simulation noise) as a proportion of the maximum absolute
value over all valuesnSV
- Number of singular values to keep from the singular value
decomposition (SVD)quiet
- Turn off logging?public WeightedCostApproximator(float[][][] evaluationSignals, float[][][] values, Function costFunction, float noise, int nSV, boolean quiet)
evaluationSignals
- Signals over which error is evaluated. First dimension is for each
evaluation signal. Second dimension is for the dimensions of each signal. Third dimension is
the value of the signal dimension over time.values
- The values of whatever functions are being combined, over the
evaluation signals. Commonly neuron firing rates. The first dimension makes up
the list of functions, the second the values of these functions for each evaluation
signal, and the third the value of the function over time.costFunction
- A cost function that weights squared error over the domain of
evaluation pointsnoise
- Standard deviation of Gaussian noise to add to values (to reduce
sensitivity to simulation noise) as a proportion of the maximum absolute
value over all valuesnSV
- Number of singular values to keep from the singular value
decomposition (SVD)quiet
- Turn off logging?public WeightedCostApproximator(float[][] evaluationPoints, float[][] values, Function costFunction, float noise, int nSV)
evaluationPoints
- Points at which error is evaluated (should be uniformly
distributed, as the sum of error at these points is treated as an integral
over the domain of interest). Examples include vector inputs to an ensemble,
or different points in time within different simulation regimes.values
- The values of whatever functions are being combined, at the
evaluationPoints. Commonly neuron firing rates. The first dimension makes up
the list of functions, and the second the values of these functions at each
evaluation point.costFunction
- A cost function that weights squared error over the domain of
evaluation pointsnoise
- Standard deviation of Gaussian noise to add to values (to reduce
sensitivity to simulation noise) as a proportion of the maximum absolute
value over all valuesnSV
- Number of singular values to keep from the singular value
decomposition (SVD)public static void setUseGPU(boolean use)
use
- Use the GPU?public static boolean getUseGPU()
public static boolean canUseGPU()
public static java.lang.String getGPUErrorMessage()
public float[][] getEvalPoints()
getEvalPoints
in interface LinearApproximator
LinearApproximator.getEvalPoints()
public float[][] getValues()
getValues
in interface LinearApproximator
LinearApproximator.getValues()
public double[][] pseudoInverse(double[][] matrix, float minSV, int nSV)
matrix
- Any matrixminSV
- Hint as to smallest singular value to usenSV
- Max number of singular values to usepublic float[] findCoefficients(Function target)
This implementation is adapted from Eliasmith & Anderson, 2003, appendix A.
It solves PHI = GAMMA" UPSILON, where " denotes pseudoinverse, UPSILON_i = < cost(x) x a_i(x) >, and GAMMA_ij = < cost(x) a_i(x) a_j(x) >. <> denotes integration (the sum over eval points).
findCoefficients
in interface LinearApproximator
target
- Function to approximateLinearApproximator.findCoefficients(ca.nengo.math.Function)
public float[] findCoefficients(float[] targetSignal)
targetSignal
- signal over time that the coefficients should fit topublic LinearApproximator clone() throws java.lang.CloneNotSupportedException
clone
in interface LinearApproximator
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if clone can't be made