且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

标准Keras模型输出是什么意思? Keras的时代和损失是什么?

更新时间:2023-12-02 15:27:04

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

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.