Skip to content

Instantly share code, notes, and snippets.

@manashmandal
Created January 9, 2018 11:04
Show Gist options
  • Save manashmandal/5ef0864e9746d955be9179704ed4c793 to your computer and use it in GitHub Desktop.
Save manashmandal/5ef0864e9746d955be9179704ed4c793 to your computer and use it in GitHub Desktop.
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