Fitting the model

The code for fitting the model is as follows:

# Fit model
model_two <- model %>% fit(trainx,
trainy,
epochs = 10,
batch_size = 10,
validation_split = 0.2)

From the preceding code, we can observe the following:

  • We train the network with 10 epochs and with a batch size of 10.
  • We specify 20% (or 400 images) to be used for assessing the validation loss and validation accuracy, and the remaining 80% (or 1,600 images) for training.

The plot of the accuracy and loss values after training the model is as follows:

From the plot for the loss and accuracy values, we can make the following observations:

  • There is an important difference compared to the previous plot, where the pretrained model wasn't used. This plot shows us that the model reaches an accuracy of over 60% by the second epoch itself compared to the previous plot, where it remained below 25%. Thus, we can see that the use of a pretrained model has an immediate impact on image classification.
  • The improvements based on validation data are slow compared to those for the training data.
  • Although the accuracy values based on the validation data show gradual improvement, the loss values for the validation data show more variability.

In the next section, we will evaluate the model and assess its prediction performance.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset