Class Sum<T extends TNumber>
java.lang.Object
org.tensorflow.framework.metrics.BaseMetric
org.tensorflow.framework.metrics.Sum<T>
- All Implemented Interfaces:
Metric
Computes the (weighted) sum of the given values.
For example, if values is [1, 3, 5, 7] then the sum is 16. If the weights were
specified as [1, 1, 0, 0], then the sum would be 4.
This metric creates one variable, total, that is used to compute the sum of values.
This is ultimately returned as sum.
If sample_weight is None, weights default to 1. Use sample_weight of 0 to mask values.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCount()Gets the count variableGets the type for the variablesgetTotal()Gets the total variableprotected 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> values, Operand<? extends TNumber> sampleWeights) Updates the metric variables based on the inputs.Methods inherited from class BaseMetric
callOnce, checkIsGraph, getName, getSeed, getTF, getVariableName, isInitialized, setInitialized, setName, setTF, updateState, updateState, updateStateList
-
Field Details
-
TOTAL
- See Also:
-
COUNT
- See Also:
-
reduction
-
total
-
count
the variable that holds the count of the metric values. ForMetricReduction.WEIGHTED_MEAN, this count may be weighted
-
-
Constructor Details
-
Sum
Creates a Sum metric with a name ofClass.getSimpleName()- 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 type for the variables and result
-
Sum
Creates a Sum metric.- Parameters:
name- the name of the metric instance. If null, 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 type for the variables and result
-
-
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> values, Operand<? extends TNumber> sampleWeights) Updates the metric variables based on the inputs. At least one input arg required forvalues, an optional additional input for thesampleWeights- Specified by:
updateStateListin interfaceMetric- Overrides:
updateStateListin classBaseMetric- Parameters:
tf- the TensorFlow Ops encapsulating aGraphenvironment.values- the inputs to be passed to update state, this may not be nullsampleWeights- sample weights to be applied to values, will default to 1 if null.- Returns:
- the result with a control dependency on update state Operands
- Throws:
IllegalArgumentException- if values is null
-
result
Gets the current result of the metric- Type Parameters:
U- the date type for the result- Parameters:
tf- the TensorFlow Ops encapsulating aGraphenvironment.type- the data type for the result- Returns:
- the result, possibly with control dependencies
-
getTotal
-
getCount
-
getInternalType
-