Keras/Tensorflow predict: error in array shape
<p>I'm following the <a href="https://github.com/fchollet/keras/blob/master/examples/cifar10_cnn.py" rel="noreferrer">Keras CIFAR10 tutorial here</a>.
The only changes I made were:</p>

<p>[a] added to the end of tutorial file</p>

<pre><code>model.save_weights('./weights.h5', overwrite=True)
</code></pre>

<p>[b] changed ~./keras/keras.json to</p>

<pre><code>{"floatx": "float32", "backend": "tensorflow", "epsilon": 1e-07}
</code></pre>

<p>I can run the model successfully.</p>

<p>Then I want to test a single image against the trained model. My code:</p>

<pre><code>[... similar to tutorial file with model being created and compiled...]
...
model = Sequential()
...
model.compile()

model.load_weights('./ddx_weights.h5')

img = cv2.imread('car.jpeg', -1) # this is is a 32x32 RGB image
img = np.array(img)
y_pred = model.predict_classes(img, 1)
print(y_pred)
</code></pre>

<p>I get this error:</p>

<pre><code>ValueError: Cannot feed value of shape (1, 32, 3) for Tensor 'convolution2d_input_1:0', which has shape '(?, 3, 32, 32)'
</code></pre>

<p>What is the correct way of reshaping the input data for a single image to be tested?</p>

<p>I have <strong>not</strong> added <code>"image_dim_ordering": "tf"</code> in <code>./keras/keras.json</code>.</p>