import tensorflow
from tensorflow.keras.datasets import mnist
from tensorflow.keras.models import load_model
from tensorflow.keras.layers import Dropout, Flatten
import matplotlib.pyplot as plt
(trainX, trainY), (testX, testY) = mnist.load_data()
img_rows, img_cols = 28, 28
trainX = trainX.reshape(trainX.shape[0], img_rows, img_cols, 1)
testX = testX.reshape(testX.shape[0], img_rows, img_cols, 1)
input_shape = (img_rows, img_cols, 1) # 1 karena grayscale, 3 untuk berwarna
trainX = trainX.astype('float32')
testX = testX.astype('float32')
trainX /= 255
testX /= 255
testY = tensorflow.keras.utils.to_categorical(testY, 10)
model = load_model("mnist.h5")
score = model.evaluate(testX, testY)
print(score)
Comments