标准Keras模型输出是什么意思? Keras的时代和损失是什么? [英] What does the standard Keras model output mean? What is epoch and loss in Keras?

查看:117
本文介绍了标准Keras模型输出是什么意思? Keras的时代和损失是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用Keras构建了我的第一个模型,这是输出.看起来像建立任何Keras人工神经网络后获得的标准输出.即使查阅了文档,我仍然不完全理解什么是纪元,输出中显示的是什么损失.

I have just built my first model using Keras and this is the output. It looks like the standard output you get after building any Keras artificial neural network. Even after looking in the documentation, I do not fully understand what the epoch is and what the loss is which is printed in the output.

Keras中的时代和损失是什么?

(我知道这可能是一个非常基本的问题,但是我似乎无法在线找到答案,如果答案真的很难从文档中找到,我认为其他人也会有同样的问题,因此决定张贴在这里.)

(I know it's probably an extremely basic question, but I couldn't seem to locate the answer online, and if the answer is really that hard to glean from the documentation I thought others would have the same question and thus decided to post it here.)

Epoch 1/20
1213/1213 [==============================] - 0s - loss: 0.1760     
Epoch 2/20
1213/1213 [==============================] - 0s - loss: 0.1840     
Epoch 3/20
1213/1213 [==============================] - 0s - loss: 0.1816     
Epoch 4/20
1213/1213 [==============================] - 0s - loss: 0.1915     
Epoch 5/20
1213/1213 [==============================] - 0s - loss: 0.1928     
Epoch 6/20
1213/1213 [==============================] - 0s - loss: 0.1964     
Epoch 7/20
1213/1213 [==============================] - 0s - loss: 0.1948     
Epoch 8/20
1213/1213 [==============================] - 0s - loss: 0.1971     
Epoch 9/20
1213/1213 [==============================] - 0s - loss: 0.1899     
Epoch 10/20
1213/1213 [==============================] - 0s - loss: 0.1957     
Epoch 11/20
1213/1213 [==============================] - 0s - loss: 0.1923     
Epoch 12/20
1213/1213 [==============================] - 0s - loss: 0.1910     
Epoch 13/20
1213/1213 [==============================] - 0s - loss: 0.2104     
Epoch 14/20
1213/1213 [==============================] - 0s - loss: 0.1976     
Epoch 15/20
1213/1213 [==============================] - 0s - loss: 0.1979     
Epoch 16/20
1213/1213 [==============================] - 0s - loss: 0.2036     
Epoch 17/20
1213/1213 [==============================] - 0s - loss: 0.2019     
Epoch 18/20
1213/1213 [==============================] - 0s - loss: 0.1978     
Epoch 19/20
1213/1213 [==============================] - 0s - loss: 0.1954     
Epoch 20/20
1213/1213 [==============================] - 0s - loss: 0.1949

推荐答案

仅是为了更明确地回答问题,以下是时代和损失的定义:

Just to answer the questions more specifically, here's a definition of epoch and loss:

培训:全面访问您的所有培训数据.

Epoch: A full pass over all of your training data.

例如,在上面的视图中,您有1213个观测值.因此,当您完成对所有1213个观测值的训练通行证时,纪元就结束了.

For example, in your view above, you have 1213 observations. So an epoch concludes when it has finished a training pass over all 1213 of your observations.

损失:我们在模型训练期间尝试最小化的标量值.损失越低,我们的预测就越接近真实标签.

Loss: A scalar value that we attempt to minimize during our training of the model. The lower the loss, the closer our predictions are to the true labels.

这通常是均方误差(MSE),如David Maust所说,或经常在Keras中使用,分类交叉熵

This is usually Mean Squared Error (MSE) as David Maust said above, or often in Keras, Categorical Cross Entropy

从Keras模型的拟合运行中,您期望看到的是n个时期内的损耗减少.您的训练相当不正常,因为您的损失实际上正在增加. 可能是由于学习率太大而导致的最佳化过冲.

What you'd expect to see from running fit on your Keras model, is a decrease in loss over n number of epochs. Your training run is rather abnormal, as your loss is actually increasing. This could be due to a learning rate that is too large, which is causing you to overshoot optima.

正如jaycode所提到的,您将要查看模型在未见数据上的性能,因为这是机器学习的一般用例.

As jaycode mentioned, you will want to look at your model's performance on unseen data, as this is the general use case of Machine Learning.

因此,您应该在编译方法中包括一系列指标,如下所示:

As such, you should include a list of metrics in your compile method, which could look like:

model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])

以及在fit方法期间在验证时运行模型,例如:

As well as run your model on validation during the fit method, such as:

model.fit(data, labels, validation_split=0.2)


还有很多要解释的地方,但是希望这可以帮助您入门.


There's a lot more to explain, but hopefully this gets you started.

这篇关于标准Keras模型输出是什么意思? Keras的时代和损失是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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