keras 如何定义“准确度"?和“损失"? [英] How does keras define "accuracy" and "loss"?

查看:33
本文介绍了keras 如何定义“准确度"?和“损失"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到 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.

根据定义,正则化器被添加到损失中.例如,请参见 Layer 类的/a> 方法.

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

更新

accuracy 的类型是根据目标函数确定的,参见training.py.默认选择是 categorical_accuracy.当目标函数是二进制或稀疏时,选择其他类型,如 binary_accuracysparse_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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆