Skip to content

Instantly share code, notes, and snippets.

@wmlba
Last active April 21, 2019 10:26
Show Gist options
  • Save wmlba/8a5a8996a14c41e8a1e2de98ca6bfffb to your computer and use it in GitHub Desktop.
Save wmlba/8a5a8996a14c41e8a1e2de98ca6bfffb to your computer and use it in GitHub Desktop.
%matplotlib inline
from keras.preprocessing import image
# if the img.png is not one of the MNIST dataset that the model was trained on, the error will be very high.
img = image.load_img("./img.png", target_size=(28, 28), color_mode = "grayscale")
input_img = image.img_to_array(img)
inputs = input_img.reshape(1,784)
target_data = autoencoder.predict(inputs)
dist = np.linalg.norm(inputs - target_data, axis=-1)
print(dist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment