hendriawan

day2-03-cnn-predicted

Nov 29th, 2022 (edited)
1,245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. import tensorflow
  2. import numpy as np
  3. from tensorflow.keras.datasets import mnist
  4. from tensorflow.keras.models import load_model
  5. from tensorflow.keras.layers import Dropout, Flatten
  6.  
  7. import matplotlib.pyplot as plt
  8.  
  9. (trainX, trainY), (testX, testY) = mnist.load_data()
  10. plt.imshow(testX[8])
  11. plt.show()
  12.  
  13. img_rows, img_cols = 28, 28
  14. testImg = testX[8].reshape(1,img_rows,img_cols,1)
  15. testImg = testImg.astype("float32")
  16. testImg /=255
  17.  
  18.  
  19. model = load_model("mnist.h5")
  20. pred = model.predict(testImg)
  21. # print(pred.round())
  22. print(np.argmax(pred.round()))
  23.  
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment