MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / call

Method call

tensorflow/contrib/eager/python/metrics_impl.py:313–338  ·  view source on GitHub ↗

Accumulate statistics for computing the mean. For example, if values is [1, 3, 5, 7] then the mean is 4. If the weights were specified as [1, 1, 0, 0] then the mean would be 2. Args: values: Tensor with the per-example value. weights: Optional weighting of each example. Def

(self, values, weights=None)

Source from the content-addressed store, hash-verified

311 initializer=init_ops.zeros_initializer)
312
313 def call(self, values, weights=None):
314 """Accumulate statistics for computing the mean.
315
316 For example, if values is [1, 3, 5, 7] then the mean is 4.
317 If the weights were specified as [1, 1, 0, 0] then the mean would be 2.
318
319 Args:
320 values: Tensor with the per-example value.
321 weights: Optional weighting of each example. Defaults to 1.
322
323 Returns:
324 The arguments, for easy chaining.
325 """
326 if weights is None:
327 self.denom.assign_add(
328 math_ops.cast(array_ops.identity(array_ops.size(values)), self.dtype))
329 values = math_ops.reduce_sum(values)
330 self.numer.assign_add(math_ops.cast(values, self.dtype))
331 else:
332 weights = math_ops.cast(weights, self.dtype)
333 self.denom.assign_add(math_ops.reduce_sum(weights))
334 values = math_ops.cast(values, self.dtype) * weights
335 self.numer.assign_add(math_ops.reduce_sum(values))
336 if weights is None:
337 return values
338 return values, weights
339
340 def result(self, write_summary=True):
341 """Returns the result of the Metric.

Callers 4

callMethod · 0.45
callMethod · 0.45
callMethod · 0.45
callMethod · 0.45

Calls 5

reduce_sumMethod · 0.80
assign_addMethod · 0.45
castMethod · 0.45
identityMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected