title: Invalid dimension for image data in plt.imshow()
body: <p>I am using mnist dataset for training a capsule network in keras background.
  After training, I want to display an image from mnist dataset. For loading images, mnist.load_data() is used. The data is stored as (x_train, y_train),(x_test, y_test).
  Now, for visualizing image, my code is as follows:</p>
  
  <pre><code>img_path = x_test[1]  
  print(img_path.shape)
  plt.imshow(img_path)
  plt.show()
  </code></pre>
  
  <p>The code gives output as follows:</p>
  
  <pre><code>(28, 28, 1)
  </code></pre>
  
  <p>and the error on plt.imshow(img_path) as follows:</p>
  
  <pre><code>TypeError: Invalid dimensions for image data
  </code></pre>
  
  <p>How to show image in png format. Help!</p>