Deep Learning with Keras Tutorial
Selected Reading
- Deep Learning with Keras - Discussion
- Deep Learning with Keras - Useful Resources
- Deep Learning with Keras - Quick Guide
- Conclusion
- Loading Model for Predictions
- Saving Model
- Predicting on Test Data
- Evaluating Model Performance
- Training the Model
- Preparing Data
- Compiling the Model
- Creating Deep Learning Model
- Importing Libraries
- Setting up Project
- Deep Learning
- Deep Learning with Keras - Introduction
- Deep Learning with Keras - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Training the Model
Deep Learning with Keras - Training the Model
The model training is done in one single method call called fit that takes few parameters as seen in the code below −
history = model.fit(X_train, Y_train, batch_size=128, epochs=20, verbose=2, vapdation_data=(X_test, Y_test)))
The first two parameters to the fit method specify the features and the output of the training dataset.
The epochs is set to 20; we assume that the training will converge in max 20 epochs - the iterations. The trained model is vapdated on the test data as specified in the last parameter.
The partial output of running the above command is shown here −
Train on 60000 samples, vapdate on 10000 samples Epoch 1/20 - 9s - loss: 0.2488 - acc: 0.9252 - val_loss: 0.1059 - val_acc: 0.9665 Epoch 2/20 - 9s - loss: 0.1004 - acc: 0.9688 - val_loss: 0.0850 - val_acc: 0.9715 Epoch 3/20 - 9s - loss: 0.0723 - acc: 0.9773 - val_loss: 0.0717 - val_acc: 0.9765 Epoch 4/20 - 9s - loss: 0.0532 - acc: 0.9826 - val_loss: 0.0665 - val_acc: 0.9795 Epoch 5/20 - 9s - loss: 0.0457 - acc: 0.9856 - val_loss: 0.0695 - val_acc: 0.9792
The screenshot of the output is given below for your quick reference −
Now, as the model is trained on our training data, we will evaluate its performance.
Advertisements