用法
compute_metrics(
    x, y, y_pred, sample_weight
)參數
- 
x輸入數據。
- 
y目標數據。
- 
y_pred模型返回的預測(model.call(x)的輸出)
- 
sample_weight用於加權損失函數的樣本權重。
返回
- 
一個 dict包含將傳遞給tf.keras.callbacks.CallbackList.on_train_batch_end()的值。通常,會返回self.metrics中列出的指標的值。示例:{'loss':0.2, 'accuracy':0.7}。
更新指標狀態並收集所有要返回的指標。
子類可以選擇覆蓋此方法以提供自定義指標更新和收集邏輯。
例子:
class MyModel(tf.keras.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(MyModel, self).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['custom_metric_name'] = self.custom_metric.result()
    return metric_results相關用法
- Python tf.keras.experimental.LinearModel.compute_loss用法及代碼示例
- Python tf.keras.experimental.LinearModel.compile用法及代碼示例
- Python tf.keras.experimental.LinearModel.save用法及代碼示例
- Python tf.keras.experimental.LinearModel.save_spec用法及代碼示例
- Python tf.keras.experimental.LinearModel.reset_metrics用法及代碼示例
- Python tf.keras.experimental.LinearModel用法及代碼示例
- Python tf.keras.experimental.WideDeepModel.compute_loss用法及代碼示例
- Python tf.keras.experimental.SequenceFeatures用法及代碼示例
- Python tf.keras.experimental.WideDeepModel用法及代碼示例
- Python tf.keras.experimental.PeepholeLSTMCell用法及代碼示例
- Python tf.keras.experimental.WideDeepModel.reset_metrics用法及代碼示例
- Python tf.keras.experimental.WideDeepModel.save_spec用法及代碼示例
- Python tf.keras.experimental.WideDeepModel.save用法及代碼示例
- Python tf.keras.experimental.WideDeepModel.compute_metrics用法及代碼示例
- Python tf.keras.experimental.WideDeepModel.compile用法及代碼示例
- Python tf.keras.estimator.model_to_estimator用法及代碼示例
- Python tf.keras.applications.inception_resnet_v2.preprocess_input用法及代碼示例
- Python tf.keras.metrics.Mean.merge_state用法及代碼示例
- Python tf.keras.layers.InputLayer用法及代碼示例
- Python tf.keras.callbacks.ReduceLROnPlateau用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.keras.experimental.LinearModel.compute_metrics。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
