Class Recall<T extends TNumber>
java.lang.Object
org.tensorflow.framework.metrics.BaseMetric
org.tensorflow.framework.metrics.Recall<T>
- Type Parameters:
T- The data type for the metric result
- All Implemented Interfaces:
Metric
Computes the recall of the predictions with respect to the labels.
This metric creates two local variables, truePositives and falseNegatives ,
that are used to compute the recall. This value is ultimately returned as recall, an idempotent
operation that simply divides truePositives by the sum of truePositives and
falseNegatives.
If sampleWeights is null, weights default to 1. Use sampleWeights of 0 to mask
values.
If topK is set, the metric calculates recall as how often on average a class among the
labels of a batch entry is in the top-k predictions.
If classId is specified, the metric calculates recall by considering only the entries
in the batch for which classId is in the label, and computing the fraction of them for
which classId is above the threshold and/or in the top-k predictions.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a Recall metric with a name ofClass.getSimpleName(), and topK and classId set to null.Creates a Recall metric with a name ofClass.getSimpleName()Creates a Recall metric with a name ofClass.getSimpleName(), and topK and classId set to null.Creates a Recall metric with a name ofClass.getSimpleName()Creates a Recall metric with a name ofClass.getSimpleName(), and topK and classId set to null, and thresholds set toDEFAULT_THRESHOLDCreates a Recall metric with a name ofClass.getSimpleName()and using a threshold value ofDEFAULT_THRESHOLD.Creates a Recall metric with topK and classId set to null.Creates a Recall metric.Creates a Recall metric with topK and classId set to null.Creates a Recall metric.Creates a Recall metric with topK and classId set to null and thresholds set toDEFAULT_THRESHOLD.Creates a Recall metric using a threshold value ofDEFAULT_THRESHOLD. -
Method Summary
Modifier and TypeMethodDescriptionGets the class idGets the falseNegatives variableGets the falseNegatives variable namefloat[]Gets the thresholdsgetTopK()Gets the topK valueGets the truePositives variableGets the truePositives variable nameprotected voidInitialize the TensorFlow OpsresetStates(Ops tf) Resets any state variables to their initial valuesGets the current result of the metricupdateStateList(Ops tf, Operand<? extends TNumber> labels, Operand<? extends TNumber> predictions, Operand<? extends TNumber> sampleWeights) Accumulates true positive and false negative statistics.Methods inherited from class BaseMetric
callOnce, checkIsGraph, getName, getSeed, getTF, getVariableName, isInitialized, setInitialized, setName, setTF, updateState, updateState, updateStateList
-
Field Details
-
DEFAULT_THRESHOLD
public static final float DEFAULT_THRESHOLD- See Also:
-
TRUE_POSITIVES
- See Also:
-
FALSE_NEGATIVES
- See Also:
-
-
Constructor Details
-
Recall
Creates a Recall metric with a name ofClass.getSimpleName(), and topK and classId set to null, and thresholds set toDEFAULT_THRESHOLD- Parameters:
seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
Recall
Creates a Recall metric with topK and classId set to null and thresholds set toDEFAULT_THRESHOLD.- Parameters:
name- name of the metric instance. If null, name defaults toClass.getSimpleName().seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
Recall
Creates a Recall metric with a name ofClass.getSimpleName(), and topK and classId set to null.- Parameters:
threshold- A threshold is compared with prediction values to determine the truth value of predictions (i.e., above the threshold is `true`, below is `false`). If null, defaults toDEFAULT_THRESHOLD.seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
Recall
Creates a Recall metric with a name ofClass.getSimpleName(), and topK and classId set to null.- Parameters:
thresholds- A threshold is compared with prediction values to determine the truth value of predictions (i.e., above the threshold is `true`, below is `false`). If null, defaults toDEFAULT_THRESHOLD.seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
Recall
Creates a Recall metric with topK and classId set to null.- Parameters:
name- name of the metric instance. If null, name defaults toClass.getSimpleName().threshold- A threshold is compared with prediction values to determine the truth value of predictions (i.e., above the threshold is `true`, below is `false`). If null, defaults toDEFAULT_THRESHOLD.seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
Recall
Creates a Recall metric with topK and classId set to null.- Parameters:
name- name of the metric instance. If null, name defaults toClass.getSimpleName().thresholds- A threshold is compared with prediction values to determine the truth value of predictions (i.e., above the threshold is `true`, below is `false`). If null, defaults toDEFAULT_THRESHOLD.seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
Recall
Creates a Recall metric with a name ofClass.getSimpleName()and using a threshold value ofDEFAULT_THRESHOLD.- Parameters:
topK- An optional value specifying the top-k predictions to consider when calculating precision.classId- Optional Integer class ID for which we want binary metrics. This must be in the half-open interval [0, numClasses], where numClasses is the last dimension of predictions.seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
Recall
Creates a Recall metric using a threshold value ofDEFAULT_THRESHOLD.- Parameters:
name- name of the metric instance. If null, name defaults toClass.getSimpleName().topK- An optional value specifying the top-k predictions to consider when calculating precision.classId- Optional Integer class ID for which we want binary metrics. This must be in the half-open interval [0, numClasses], where numClasses is the last dimension of predictions.seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
Recall
Creates a Recall metric with a name ofClass.getSimpleName()- Parameters:
threshold- A threshold is compared with prediction values to determine the truth value of predictions (i.e., above the threshold is `true`, below is `false`). If null, defaults toDEFAULT_THRESHOLD.topK- An optional value specifying the top-k predictions to consider when calculating precision.classId- Optional Integer class ID for which we want binary metrics. This must be in the half-open interval [0, numClasses], where numClasses is the last dimension of predictions.seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
Recall
Creates a Recall metric with a name ofClass.getSimpleName()- Parameters:
thresholds- A threshold is compared with prediction values to determine the truth value of predictions (i.e., above the threshold is `true`, below is `false`). If null, defaults toDEFAULT_THRESHOLD.topK- An optional value specifying the top-k predictions to consider when calculating precision.classId- Optional Integer class ID for which we want binary metrics. This must be in the half-open interval [0, numClasses], where numClasses is the last dimension of predictions.seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
Recall
public Recall(String name, float threshold, Integer topK, Integer classId, long seed, Class<T> type) Creates a Recall metric.- Parameters:
name- name of the metric instance. If null, name defaults toClass.getSimpleName().threshold- A threshold is compared with prediction values to determine the truth value of predictions (i.e., above the threshold is `true`, below is `false`). If null, defaults toDEFAULT_THRESHOLD.topK- An optional value specifying the top-k predictions to consider when calculating precision.classId- Optional Integer class ID for which we want binary metrics. This must be in the half-open interval [0, numClasses], where numClasses is the last dimension of predictions.seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
Recall
public Recall(String name, float[] thresholds, Integer topK, Integer classId, long seed, Class<T> type) Creates a Recall metric.- Parameters:
name- name of the metric instance. If null, name defaults toClass.getSimpleName().thresholds- A threshold is compared with prediction values to determine the truth value of predictions (i.e., above the threshold is `true`, below is `false`). If null, defaults toDEFAULT_THRESHOLD.topK- An optional value specifying the top-k predictions to consider when calculating precision.classId- Optional Integer class ID for which we want binary metrics. This must be in the half-open interval [0, numClasses], where numClasses is the last dimension of predictions.seed- the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.type- the data type for the variables
-
-
Method Details
-
init
Initialize the TensorFlow Ops- Specified by:
initin classBaseMetric- Parameters:
tf- the TensorFlow Ops encapsulating aGraphenvironment.
-
resetStates
-
updateStateList
public List<Op> updateStateList(Ops tf, Operand<? extends TNumber> labels, Operand<? extends TNumber> predictions, Operand<? extends TNumber> sampleWeights) Accumulates true positive and false negative statistics.- Specified by:
updateStateListin interfaceMetric- Overrides:
updateStateListin classBaseMetric- Parameters:
tf- the TensorFlow Ops encapsulating aGraphenvironment. The TensorFlow Opslabels- the labels The ground truth values, with the same dimensions as predictions. Will be cast toTBool.predictions- the predictions, each element must be in the range[0, 1].sampleWeights- Optional weighting of each example. Defaults to 1. Rank is either 0, or * the same rank as labels, and must be broadcastable to labels.- Returns:
- a List of Operations to update the metric state.
- Throws:
IllegalArgumentException- if the TensorFlow Ops scope does not encapsulate a Graph environment.
-
result
-
getThresholds
public float[] getThresholds()Gets the thresholds- Returns:
- the thresholds
-
getTopK
-
getClassId
-
getTruePositives
-
getFalseNegatives
-
getTruePositivesName
Gets the truePositives variable name- Returns:
- the truePositives variable name
-
getFalseNegativesName
Gets the falseNegatives variable name- Returns:
- the falseNegatives variable name
-