Class Evaluator
- Direct Known Subclasses:
AbstractAccuracy,BoundingBoxError,IndexEvaluator,Loss
Evaluators that can be used to evaluate the performance of a model.
The Evaluators can all be monitored to make an assessment about the performance of the
model. However, only ones that further extend Loss are suited to
being used to directly optimize a model.
In addition to computing the evaluation, an evaluator can accumulate values to compute a total
evaluation. For different purposes, it is possible to have multiple accumulators on a single
evaluator. Each accumulator must be added with a String key to identify the accumulator. Before
using an accumulator, you must addAccumulator(String). Then, call updateAccumulator(String, NDList, NDList) to add more data to the accumulator. You can
use getAccumulator(String) to retrieve the accumulated value and resetAccumulator(String) to reset the accumulator to the same value as when just
added.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddAccumulator(String key) Adds an accumulator for the results of the evaluation with the given key.protected voidcheckLabelShapes(NDArray labels, NDArray predictions) Checks the length of NDArrays.protected voidcheckLabelShapes(NDArray labels, NDArray predictions, boolean checkDimOnly) Checks if the two inputNDArrayhave the same length or shape.abstract NDArrayCalculates the evaluation between the labels and the predictions.abstract floatgetAccumulator(String key) Returns the accumulated evaluator value.getName()Returns the name of thisEvaluator.abstract voidresetAccumulator(String key) Resets the evaluator value with the given key.abstract voidupdateAccumulator(String key, NDList labels, NDList predictions) Updates the evaluator with the given key based on aNDListof labels and predictions.voidupdateAccumulators(String[] keys, NDList labels, NDList predictions) Updates the evaluator with the given keys based on aNDListof labels and predictions.
-
Field Details
-
totalInstances
-
-
Constructor Details
-
Evaluator
Creates an evaluator with abstract update methods.- Parameters:
name- the name of the evaluator
-
-
Method Details
-
getName
Returns the name of thisEvaluator.- Returns:
- the name of this
Evaluator
-
evaluate
Calculates the evaluation between the labels and the predictions.- Parameters:
labels- the correct valuespredictions- the predicted values- Returns:
- the evaluation result
-
addAccumulator
Adds an accumulator for the results of the evaluation with the given key.- Parameters:
key- the key for the new accumulator
-
updateAccumulators
Updates the evaluator with the given keys based on aNDListof labels and predictions.This is a synchronized operation. You should only call it at the end of a batch or epoch.
This is an alternative to @{link
updateAccumulator(String, NDList, NDList)} that may be more efficient when updating multiple accumulators at once.- Parameters:
keys- the keys of all the accumulators to updatelabels- aNDListof labelspredictions- aNDListof predictions
-
updateAccumulator
Updates the evaluator with the given key based on aNDListof labels and predictions.This is a synchronized operation. You should only call it at the end of a batch or epoch.
- Parameters:
key- the key of the accumulator to updatelabels- aNDListof labelspredictions- aNDListof predictions
-
resetAccumulator
Resets the evaluator value with the given key.- Parameters:
key- the key of the accumulator to reset
-
getAccumulator
Returns the accumulated evaluator value.- Parameters:
key- the key of the accumulator to get- Returns:
- the accumulated value
- Throws:
IllegalArgumentException- if no accumulator was added with the given key
-
checkLabelShapes
Checks if the two inputNDArrayhave the same length or shape.- Parameters:
labels- aNDArrayof labelspredictions- aNDArrayof predictionscheckDimOnly- whether to check for first dimension only
-
checkLabelShapes
Checks the length of NDArrays.- Parameters:
labels- aNDArrayof labelspredictions- aNDArrayof predictions
-