compute_metrics

FullyConnected.compute_metrics(x, y, y_pred, sample_weight=None)

Update metric states and collect all metrics to be returned.

Subclasses can optionally override this method to provide custom metric updating and collection logic.

Example:

```python class MyModel(Sequential):

def compute_metrics(self, x, y, y_pred, sample_weight):

# This super call updates self.compiled_metrics and returns # results for all metrics listed in self.metrics. metric_results = super().compute_metrics(

x, y, y_pred, sample_weight)

# Note that self.custom_metric is not listed # in self.metrics. self.custom_metric.update_state(x, y, y_pred, sample_weight) metric_results[‘metric_name’] = self.custom_metric.result() return metric_results

```

Parameters:
  • x – Input data.

  • y – Target data.

  • y_pred – Predictions returned by the model output of model.call(x).

  • sample_weight – Sample weights for weighting the loss function.

Returns:

A dict containing values that will be passed to keras.callbacks.CallbackList.on_train_batch_end(). Typically, the values of the metrics listed in self.metrics are returned. Example: {‘loss’: 0.2, ‘accuracy’: 0.7}.