Returns the result of the Metric. Args: write_summary: bool indicating whether to feed the result to the summary before returning. Returns: aggregated metric as float. Raises: ValueError: if the optional argument is not bool
(self, write_summary=True)
| 338 | return values, weights |
| 339 | |
| 340 | def result(self, write_summary=True): |
| 341 | """Returns the result of the Metric. |
| 342 | |
| 343 | Args: |
| 344 | write_summary: bool indicating whether to feed the result to the summary |
| 345 | before returning. |
| 346 | Returns: |
| 347 | aggregated metric as float. |
| 348 | Raises: |
| 349 | ValueError: if the optional argument is not bool |
| 350 | """ |
| 351 | # Convert the boolean to tensor for tf.cond, if it is not. |
| 352 | if not isinstance(write_summary, ops.Tensor): |
| 353 | write_summary = ops.convert_to_tensor(write_summary) |
| 354 | t = self.numer / self.denom |
| 355 | def write_summary_f(): |
| 356 | summary_ops.scalar(name=self.name, tensor=t) |
| 357 | return t |
| 358 | smart_cond.smart_cond(write_summary, |
| 359 | write_summary_f, |
| 360 | lambda: t, |
| 361 | name="") |
| 362 | return t |
| 363 | |
| 364 | |
| 365 | class Accuracy(Mean): |
no outgoing calls