from keras import metrics
model.compile(loss='mean_squared_error',
optimizer='sgd',
metrics=[metrics.mae, metrics.categorical_accuracy])
A metric function is similar to a , except that the results from evaluating a metric are not used when training the model. You may use any of the loss functions as a metric function.
Arguments
- y_true: True labels. Theano/TensorFlow tensor.
- y_pred: Predictions. Theano/TensorFlow tensor of the same shape as y_true.
Returns
Single tensor value representing the mean of the output array across all datapoints.
keras.metrics.accuracy(y_true, y_pred)
binary_accuracy
categorical_accuracy
top_k_categorical_accuracy
keras.metrics.top_k_categorical_accuracy(y_true, y_pred, k=5)
sparse_top_k_categorical_accuracy
keras.metrics.sparse_top_k_categorical_accuracy(y_true, y_pred, k=5)
clone_metric
keras.metrics.clone_metric(metric)
clone_metrics
keras.metrics.clone_metrics(metrics)
In addition to the metrics above, you may use any of the loss functions described in the loss function page as metrics.
def mean_pred(y_true, y_pred):
return K.mean(y_pred)
model.compile(optimizer='rmsprop',
loss='binary_crossentropy',