Training our model
Let’s train our model.
All the necessary tools and data are proccessed , Now it’s time for some training.
Training our Model
In order to train our model we gonna create a function named as train_model().
First create a model with the help of create_model() and then store it into model variable.
Create a tensorboard callback with create_tensorboard_callback() and store it into tensorboard variable.
Fit the model
Now fit the model with .fit() have argument as x with train_data , epochs as NUM_EPOCHS which is set as 100, pass the validation data , pass the list of callback of tensorboard,earlystopping and store it into callbacks variable.
And return model.
Let’s use the function we’ve created with train_model() and store it into model.
It will take about 5 mins to train the model as we have 1000 of images are there.
After this process, we get loss , accuracy , val_loss, val_accuracy
Loss term denote the error produced between the predicted value and the true value.
Accuracy refers to how much accurate our model is.
Val_loss and val_accuracy is the validation loss and validation accuracy.
At the time of training the loss value is higher and accuracy is lowered but as our model trained more and more, the loss value comes lower and the accuracy rate goes upward.
The question arises that why used validation data?
Validation data is used because our model is trained on training set and the trained model needs to go through the sample paper test in which the model predict for the new images which are not in training set and this will defines how accurate our model is.
Ok we’re done with training.
Tensorboard Notebook
Check our tensorboard notebook with %tensorboard
Here is the graph of how model’s accuracy increases and loss decreases. And in epoch_accuracy it is stated that after 4 the accuracy remains constant which means that after our model starts to overfitting.
Training loss and accuracy is denoted with different colors and validation loss and accuracy is denoted with different colors.
Tensorboard shows the statistics of our trained model.