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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41531695/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 01:11:47  来源:igfitidea点击:

How does keras define "accuracy" and "loss"?

pythontensorflowmachine-learningdeep-learningkeras

提问by SRobertJames

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?

我找不到 Keras 如何定义“准确性”和“损失”。我知道我可以指定不同的指标(例如 mse、交叉熵) - 但 keras 打印出标准的“准确度”。那是怎么定义的?同样对于损失:我知道我可以指定不同类型的正则化——那些是损失吗?

Ideally, I'd like to print out the equation used to define it; if not, I'll settle for an answer here.

理想情况下,我想打印出用于定义它的方程;如果没有,我会在这里回答。

采纳答案by Sergii Gryshkevych

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.

查看metrics.py,您可以在那里找到所有可用指标的定义,包括不同类型的准确性。除非您在编译模型时将准确度添加到所需指标列表中,否则不会打印准确度。

Regularizers are by definition added to the loss. For example, see add_lossmethod of the Layerclass.

正则化器根据定义添加到损失中。例如,参见类的add_loss方法Layer

Update

更新

The type of accuracyis determined based on the objective function, see training.py. The default choice is categorical_accuracy. Other types like binary_accuracyand sparse_categorical_accuracyare selected when the objective function is either binary or sparse.

的类型accuracy是根据目标函数确定的,请参见training.py。默认选择是categorical_accuracy。当目标函数是二元函数或稀疏函数时binary_accuracysparse_categorical_accuracy会选择其他类型,例如和。