One of the most satisfying things after training a deep learning model is to actually use it in an application. For now, we'll limit ourselves to using the model with a sample that we randomly pick from our test set. But, later on, in Chapter 7, Deploying Models to Production, we'll look at how to save the model to disk and use it in C# or .NET to build applications with it.
Let's write the code to make a prediction with the neural network that we trained:
sample_index = np.random.choice(X_test.shape[0])
sample = X_test[sample_index]
inverted_mapping = {
1: 'Iris-setosa',
2: 'Iris-versicolor',
3: 'Iris-virginica'
}
prediction = z(sample)
predicted_label = inverted_mapping[np.argmax(prediction)]
print(predicted_label)
Follow the given steps:
- First, pick a random item from the test set using...