Skip to content

Instantly share code, notes, and snippets.

@korkmazkadir
Created April 1, 2018 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korkmazkadir/ab2f7a4f7d295ef2c466031851795465 to your computer and use it in GitHub Desktop.
Save korkmazkadir/ab2f7a4f7d295ef2c466031851795465 to your computer and use it in GitHub Desktop.
from keras import backend as K
import numpy as p
output = model.predict_classes(x_test, verbose=1)
wrong_classified = []
wrong_classified_value = []
wrong_classified_real = []
for i in range(0, 10000):
if output[i] != numpy.argmax(y_test[i]):
wrong_classified.append( x_test[i] )
wrong_classified_value.append( output[i] )
wrong_classified_real.append( numpy.argmax(y_test[i]) )
for idx, val in enumerate( wrong_classified_value ):
print( idx , " - wrong classified ---> ", val , "Real value --> ",wrong_classified_real[idx])
def image_data(arr):
two_d = (np.reshape(arr, (28, 28)) * 255).astype(np.uint8)
return two_d
sub_plot_rows = 3
sub_plot_columns = 6
f, axarr = plt.subplots(sub_plot_rows,sub_plot_columns)
for i in range(0, sub_plot_rows):
k = 0;
for j in range(0, sub_plot_columns):
title = str(wrong_classified_real[ k * 2 + j]) + " - " + str( wrong_classified_value[k * 2 + j])
axarr[i,j].get_xaxis().set_visible(False)
axarr[i,j].get_yaxis().set_visible(False)
axarr[i,j].set_title( title );
axarr[i,j].imshow(image_data(wrong_classified[ k * 2 + j]), interpolation='nearest' )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment