November 2018
Intermediate to advanced
492 pages
12h 19m
English
The next code block show how to use the VGG-16 model learned to predict the probability of whether an image is dog or cat from the test images dataset:
test_data = process_test_data()len(test_data)X_test = np.array([i for i in test_data]).reshape(-1,IMG_SIZE,IMG_SIZE,3)probs = model.predict(X_test)probs = np.round(probs,2)pylab.figure(figsize=(20,20))for i in range(100): pylab.subplot(10,10,i+1), pylab.imshow(X_test[i,:,:,::-1]), pylab.axis('off') pylab.title("{}, prob={:0.2f}".format('cat' if probs[i][1] < 0.5 else 'dog', max(probs[i][0],probs[i][1])))pylab.show()
The next screenshot shows the class predicted the first 100 test images along with the prediction probabilities. As can be seen in the following output, ...
Read now
Unlock full access