import matplotlib.pyplot as plt
from keras.preprocessing import image
inx = 5000
x = x_train[inx]
x = x.reshape((1, ) + x.shape)
i = 1
for batch in datagen.flow(x, batch_size=1):
plt.figure(i)
imgplot = plt.imshow(image.array_to_img(batch[0]))
i += 1
if i % 20 == 0:
break
plt.show()