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

Method _eager_add_metric

tensorflow/python/keras/engine/base_layer.py:1875–1893  ·  view source on GitHub ↗
(self, value, aggregation=None, name=None)

Source from the content-addressed store, hash-verified

1873 return match[0]
1874
1875 def _eager_add_metric(self, value, aggregation=None, name=None):
1876 # If the given metric is available in `metrics` list we just update state
1877 # on it, otherwise we create a new metric instance and
1878 # add it to the `metrics` list.
1879 metric_obj = getattr(value, '_metric_obj', None)
1880 if metric_obj:
1881 name = metric_obj.name
1882
1883 match = self._get_existing_metric(name)
1884 if match:
1885 # Tensors that come from a Metric object already updated the Metric state.
1886 if not metric_obj:
1887 match(value)
1888 return
1889
1890 if not metric_obj:
1891 assert aggregation is not None
1892 metric_obj, _ = base_layer_utils.create_mean_metric(value, name)
1893 self._metrics.append(metric_obj)
1894
1895 def _symbolic_add_metric(self, value, aggregation=None, name=None):
1896 base_layer_utils.check_graph_consistency(value, method='add_metric')

Callers 1

add_metricMethod · 0.95

Calls 2

_get_existing_metricMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected