From the course: Deep Learning: Getting Started

Training and evaluation

From the course: Deep Learning: Getting Started

Training and evaluation

- We have now prepared the input data and created a model in the previous videos. Let's now go ahead and train a model. The core block for this video is in section 4.4 of the notebook. We set the variables flat to one, so Iris will print out details of progress during training. We then set the hyper parameters for training. These are of course set initially on intuition and then fine tuned on experimentation as we improve the model. We set the batch size to 16, which is in the two power end range. We set the number of epochs to 10. We will use a validation split of 20%. This means that 20% of the training data will be used by carers for validation after each epoch. Though the recommended percentage of validation is 10, we are using more samples since the total sample size is only 150. Training a model is straightforward in carers with a single function call. The model.fit method is used to train and also capture details about the training. The first parameter is the input feature variable followed by the target variable. Then we set values for batch size, epochs, verbose and validation split. This function will initialize the weights and biases, but from gradient descent and stowed the final weights and biases in the model. It also can expose the history of training as a return value. We use this history and plot the accuracy of in sample predictions against the epochs. Finally, we will evaluate the model against the test data set and print the results. Let's run this code and review the results. We see the training progress printed after each epoch. It shows the total amount of time taken, and the last computed by the cost function. It also prints the accuracy of predictions against the in sample dataset. Additionally, it prints the loss and accuracy of predictions against the validation data set. From the plot, we can observe that as the number of epochs increases, the accuracy also increases progressively and reaches about 90%. If accuracy at this point is not acceptable, we can increase the number of epochs and retry. The evaluation against a test dataset also shows an accuracy of 93%. Model building is an iterative process in the real world and requires a distinct model architecture and Hyper Parameters and retraining the model.

Contents