简体   繁体   English

keras如何定义“准确性”和“损失”?

[英]How does keras define “accuracy” and “loss”?

I can't find how Keras defines "accuracy" and "loss". 我无法找到Keras如何定义“准确性”和“损失”。 I know I can specify different metrics (eg mse, cross entropy) - but keras prints out a standard "accuracy". 我知道我可以指定不同的指标(例如mse,交叉熵) - 但keras打印出标准的“准确度”。 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. 如果没有,我会在这里找到答案。

Have a look at metrics.py , there you can find definition of all available metrics including different types of accuracy. 看看metrics.py ,您可以在那里找到所有可用指标的定义,包括不同类型的准确性。 Accuracy is not printed unless you add it to the list of desired metrics when you compile your model. 除非在编译模型时将其添加到所需指标列表中,否则不会打印精度。

Regularizers are by definition added to the loss. 根据定义,规则制定者被添加到损失中。 For example, see add_loss method of the Layer class. 例如,请参阅Layer类的add_loss方法。

Update 更新

The type of accuracy is determined based on the objective function, see training.py . accuracy类型根据目标函数确定,参见training.py The default choice is categorical_accuracy . 默认选择是categorical_accuracy Other types like binary_accuracy and sparse_categorical_accuracy are selected when the objective function is either binary or sparse. 当目标函数是二元或稀疏时,选择其他类型,如binary_accuracysparse_categorical_accuracy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM