title: How to label test data using trained model with keras?
body: <p>I am working on the following keras convolutional neural network tutorial <a href="https://gist.github.com/fchollet/0830affa1f7f19fd47b06d4cf89ed44d" rel="nofollow noreferrer">https://gist.github.com/fchollet/0830affa1f7f19fd47b06d4cf89ed44d</a></p>
  
  <p>After training the model I want to test the model on sample images, and also label the images. I realize that I have to use <a href="https://keras.io/models/model/" rel="nofollow noreferrer">predict</a> method that generates an array that shows which label gets what score for a particular image. But I am having trouble using this method. If the images are in the folder <em>test_images</em> and there are 20 of them, how do I test these images and get the prediction?</p>
  
  <p>This is how I've gotten with one image (even though I want it for multiple images): </p>
  
  <pre><code>image = cv2.imread('test1.jpg')
  image = cv2.resize(image,(224,224))
  features = np.swapaxes(np.swapaxes(image, 1, 2), 0, 1)
  predictions = model.predict(features)
  </code></pre>
  
  <p>This throws the following error:</p>
  
  <pre><code>ValueError: Error when checking : expected conv2d_1_input to have 4 dimensions, but got array with shape (3, 224, 224)
  </code></pre>
  
  <p>Thank you very much!</p>
  
  <p>Some of the questions I consulted before:</p>
  
  <p><a href="https://stackoverflow.com/questions/45319055/simple-neural-network-in-python-not-displaying-label-for-the-test-image">Simple Neural Network in Python not displaying label for the test image</a>
  <a href="https://github.com/fchollet/keras/issues/315" rel="nofollow noreferrer">https://github.com/fchollet/keras/issues/315</a></p>