application_vnd.jupyter.stderr_output_2.png text_plain_output_1.png
import numpy as np

import tensorflow as tf

np.random.seed(4)
tf.set_random_seed(13)

mp = '.\\mnist_model.h5'
model.save(mp)

print('Usando o modelo para previsão de dígitos para a imagem: ')
unknown = np.zeros(shape=(28, 28), dtype=np.float32)
for row in range(5, 23):
    unknown[row][9] = 180
for rc in range(9, 19):
    unknown[rc][rc] = 250
plt.imshow(unknown, cmap=plt.get_cmap('gray_r'))
plt.show()
unknown = unknown.reshape(1, 28, 28, 1)
predicted = model.predict(unknown)
print('\nO valor do dígito previsto é: ')
print(predicted)