What does the standard Keras model output mean? What is epoch and loss in Keras?

前端 未结 2 1111
一生所求
一生所求 2020-12-24 01:08

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

2条回答
  •  情书的邮戳
    2020-12-24 01:34

    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.

    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.

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


    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.

    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'])
    

    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.

提交回复
热议问题