gpt4 book ai didi

keras - Keras 如何评估测试集上的损失?

转载 作者:行者123 更新时间:2023-12-04 15:08:08 37 4
gpt4 key购买 nike

我正在实现一个神经网络分类器,以打印我正在使用的这个神经网络的损失和准确性:

score = model.evaluate(x_test, y_test, verbose=False) 
model.metrics_names
print('Test score: ', score[0]) #Loss on test
print('Test accuracy: ', score[1])

我想知道 Keras 如何计算模型的损失。特别是是否在测试集的第一个(也是唯一一个)步骤中对其进行评估。
我有搜索 keras.io ,但我没有找到任何关于它的信息。

最佳答案

来自 documentation :

evaluate

Computes the loss on some input data, batch by batch.

Returns

Scalar test loss (if the model has no metrics) or list of scalars (if the model computes other metrics). The attribute model.metrics_names will give you the display labels for the scalar outputs.


因此,它会返回一个表示损失的值,或者返回与添加到模型中的不同指标相对应的值列表。这些值是基于整个测试集计算的,即。 e. x_test 中的所有值和 y_test .

关于keras - Keras 如何评估测试集上的损失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41939377/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com