如何解释Keras model.fit输出? [英] How to interpret Keras model.fit output?
问题描述
我刚刚开始使用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
文档表示适合返回
历史记录实例.其历史记录属性包含所有信息 在训练过程中收集的.
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是多少?预计到达时间:0秒??
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/80
和64/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.
loss
和acc
是指训练集的当前损耗和准确性 .
在每个时期结束时,都会根据您的验证集对您训练有素的NN进行评估.这就是val_loss
和val_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
dict的引用,最重要的是,对history
dict的引用.它在每个时期的末尾存储loss
和acc
(或任何其他使用的度量)的值.对于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:最后,您应该使用与训练集和验证集不同的测试集来测试您的NN,因此在训练过程中从未被触及过.
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屋!