CNN classifier predictions on the noised and generated images

Now, we will call the generator on the masked MNIST test data to generate images i.e fill in the missing part of the digits.

# restore missing parts of the digit with the generator
gen_imgs_test = generator.predict(noised_test_data)
Then, we will pass the generated MNIST digits to the digit classifier we have modeled already.
# predict on the restored/generated digits
gen_pred_lab = mnist_model.predict_classes(gen_imgs_test)
print('The model model accuracy on the generated images is:',np.mean(gen_pred_lab==y_test)*100)

The MNIST CNN classifier is 87.82% accurate on the generated data. 

Here is a plot showing 10 generated images by the generator, the actual label of the generated image and the label predicted by the digit classifier after processing the generated image.

# plot of 10 generated images and their predicted label
fig=plt.figure(figsize=(8, 4))
plt.title('Generated Images')
plt.axis('off')
columns = 5
rows = 2
for i in range(0, rows*columns):
fig.add_subplot(rows, columns, i+1)
plt.title('Act: %d, Pred: %d'%(gen_pred_lab[i],y_test[i])) # label
plt.axis('off') # turn off axis
plt.imshow(upscale(np.squeeze(gen_imgs_test[i])), cmap='gray') # gray scale
plt.show()
Figure 14.13:  Plot of MNIST classifier predictions on the generated images
..................Content has been hidden....................

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