keras如何定义“准确性"?和“损失"? [英] How does keras define "accuracy" and "loss"?
问题描述
我找不到Keras如何定义准确性"和损失".我知道我可以指定不同的指标(例如mse,交叉熵),但是keras会打印出标准的准确性".如何定义?同样对于损失:我知道我可以指定不同类型的正则化-损失中的正则化类型是什么?
I can't find how Keras defines "accuracy" and "loss". I know I can specify different metrics (e.g. mse, cross entropy) - but keras prints out a standard "accuracy". How is that defined? Likewise for loss: I know I can specify different types of regularization -- are those in the loss?
理想情况下,我想打印出用于定义它的方程式;如果没有,我将在这里为您解决问题.
Ideally, I'd like to print out the equation used to define it; if not, I'll settle for an answer here.
推荐答案
看看 metrics.py
,您可以在其中找到所有可用指标的定义,包括不同类型的准确性.除非在编译模型时将精度添加到所需指标列表中,否则不会打印精度.
Have a look at metrics.py
, there you can find definition of all available metrics including different types of accuracy. Accuracy is not printed unless you add it to the list of desired metrics when you compile your model.
根据定义,调节器会添加到损失中.例如,请参见 add_loss
方法Layer
类.
Regularizers are by definition added to the loss. For example, see add_loss
method of the Layer
class.
更新
accuracy
的类型取决于目标函数,请参见 training.py
.默认选择为 categorical_accuracy
.当目标函数是二进制或稀疏时,将选择其他类型,例如binary_accuracy
和sparse_categorical_accuracy
.
The type of accuracy
is determined based on the objective function, see training.py
. The default choice is categorical_accuracy
. Other types like binary_accuracy
and sparse_categorical_accuracy
are selected when the objective function is either binary or sparse.
这篇关于keras如何定义“准确性"?和“损失"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!