如何解释 Keras model.fit 输出? [英] How to interpret Keras model.fit output?

查看:46
本文介绍了如何解释 Keras model.fit 输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 Keras.我正在处理的示例有一个模型,以下代码段用于运行模型

I've just started using Keras. The sample I'm working on has a model and the following snippet is used to run the model

from sklearn.preprocessing import LabelBinarizer
label_binarizer = LabelBinarizer()
y_one_hot = label_binarizer.fit_transform(y_train)

model.compile('adam', 'categorical_crossentropy', ['accuracy'])
history = model.fit(X_normalized, y_one_hot, nb_epoch=3, validation_split=0.2)

我收到以下回复:

Using TensorFlow backend. Train on 80 samples, validate on 20 samples Epoch 1/3

32/80 [===========>..................] - ETA: 0s - loss: 1.5831 - acc:
0.4062 80/80 [==============================] - 0s - loss: 1.3927 - acc:
0.4500 - val_loss: 0.7802 - val_acc: 0.8500 Epoch 2/3

32/80 [===========>..................] - ETA: 0s - loss: 0.9300 - acc:
0.7500 80/80 [==============================] - 0s - loss: 0.8490 - acc:
0.8000 - val_loss: 0.5772 - val_acc: 0.8500 Epoch 3/3

32/80 [===========>..................] - ETA: 0s - loss: 0.6397 - acc:
0.8750 64/80 [=======================>......] - ETA: 0s - loss: 0.6867 - acc:
0.7969 80/80 [==============================] - 0s - loss: 0.6638 - acc:
0.8000 - val_loss: 0.4294 - val_acc: 0.8500

文档 说适合返回

历史实例.它的 history 属性包含所有信息在训练期间收集.

A History instance. Its history attribute contains all information collected during training.

有谁知道如何解释历史实例?

Does anyone know how to interpret the history instance?

例如,32/80 是什么意思?我假设 80 是样本数,但什么是 32?预计到达时间:0s ??

For example, what does 32/80 mean? I assume 80 is the number of samples but what is 32? ETA: 0s ??

推荐答案

ETA = 预计到达时间.

ETA = Estimated Time of Arrival.

80 是你的训练集的大小,32/8064/80 意味着你的批量大小为 32,当前正在处理第一批(或分别为第二批).

80 is the size of your training set, 32/80 and 64/80 mean that your batch size is 32 and currently the first batch (or the second batch respectively) is being processed.

lossacc 指的是训练集的当前损失和准确性.在每个时期结束时,根据您的验证集对您训练的神经网络进行评估.这就是 val_lossval_acc 所指的.

loss and acc refer to the current loss and accuracy of the training set. At the end of each epoch your trained NN is evaluated against your validation set. This is what val_loss and val_acc refer to.

model.fit() 返回的历史对象是一个带有一些字段的简单类,例如一个对 model 的引用,一个 params 字典,最重要的是,一个 history 字典.它在每个时期结束时存储 lossacc(或任何其他使用的指标)的值.对于 2 个时期,它看起来像这样:

The history object returned by model.fit() is a simple class with some fields, e.g. a reference to the model, a params dict and, most importantly, a history dict. It stores the values of loss and acc (or any other used metric) at the end of each epoch. For 2 epochs it will look like this:

{
    'val_loss': [16.11809539794922, 14.12947562917035],
    'val_acc': [0.0, 0.0],
    'loss': [14.890108108520508, 12.088571548461914],
    'acc': [0.0, 0.25]
}

如果您想可视化您的训练进度,这会非常方便.

This comes in very handy if you want to visualize your training progress.

注意:如果您的验证损失/准确度开始增加而您的训练损失/准确度仍在下降,则这是过度拟合的指标.

Note: if your validation loss/accuracy starts increasing while your training loss/accuracy is still decreasing, this is an indicator of overfitting.

注意 2:最后,您应该针对一些测试集测试您的神经网络,这些测试集与您的训练集和验证集不同,因此在训练过程中从未接触过.

Note 2: at the very end you should test your NN against some test set that is different from you training set and validation set and thus has never been touched during the training process.

这篇关于如何解释 Keras model.fit 输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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