Created
January 9, 2018 11:04
-
-
Save manashmandal/5ef0864e9746d955be9179704ed4c793 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def visualize(img,encoder,decoder): | |
"""Draws original, encoded and decoded images""" | |
code = encoder.predict(img[None])[0] | |
reco = decoder.predict(code[None])[0] | |
plt.subplot(1,3,1) | |
plt.title("Original") | |
plt.imshow(img) | |
plt.subplot(1,3,2) | |
plt.title("Code") | |
plt.imshow(code.reshape([code.shape[-1]//2,-1])) | |
plt.subplot(1,3,3) | |
plt.title("Reconstructed") | |
plt.imshow(reco.clip(0,1)) | |
plt.show() | |
score = autoencoder.evaluate(X_test,X_test,verbose=0) | |
print("Final MSE:",score) | |
for i in range(5): | |
img = X_test[i] | |
visualize(img,encoder,decoder) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment