Fitting the model

We will train the model using the following code:

# Fitting the model
model_one <- model %>% fit(trainx, trainy,
epochs = 30,
batch_size = 32,
validation_data = list(validx, validy))

# Loss and accuracy plot
plot(model_one)

Here, we're training the model using trainx as input and trainy as output. The model's training is carried out for 30 epochs with a batch size of 32. For assessing the validation loss and validation accuracy for each epoch during the training process, we make use of validx and validy, which we created earlier by taking approximately a 20% random sample from the training data.

The loss and accuracy values based on the train and validation data for each of the 30 epochs are stored in model_one. The following is a plot of this data:

From the preceding plot, we can make the following observations:

  • The loss values for the training and validation data reduce as we go from 1 to 30 epochs. However, the loss values for the validation data reduce at a slower pace compared to those for the training data as the training proceeds.
  • The accuracy values for the training and validation data show a similar pattern in the opposite direction.
  • Increasing the number of epochs during training is likely to improve the loss and accuracy values; however, divergence between the curves is also expected to increase, with this potentially leading to an overfitting situation.

Next, we will evaluate model_one and make predictions using training and test data.

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

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