title: Can I use cv2.cvtColor(image,cv2.COLOR_GRAY2RGB) on a batch of data?
body: <p>I am working with Inception v3, trying to use MNIST JPG images as the dataset to predict. I am running into a problem when its time to input training batches into the model. The error is because of the shape. X_batch produces a shape of (?,299,299), where as the first layer needs a shape of (?, 299, 299, 3). In a different part of my code that displaces a few examples I was able to use <code>example_image = cv2.cvtColor(example_image,cv2.COLOR_GRAY2RGB)</code> to convert the examples into RGB which gave <code>example_image.shape</code> of (299, 299, 3). My question is, am I able to use the cv2 to convert my X_batch into RGB or a part of the code to have X_batch have a shape of (?,299, 299, 3)?</p>
  
  <p>This is the part of the code that I need to have the conversion for:</p>
  
  <pre><code>from random import sample
  
  def prepare_batch(MNIST_paths_and_classes, batch_size):
      batch_paths_and_classes = sample(MNIST_paths_and_classes, batch_size)
      images = [mpimg.imread(path)[:, :] for path, labels in batch_paths_and_classes]
      prepared_images = [prepare_image(image) for image in images]
      X_batch = 2 * np.stack(prepared_images) - 1 # Inception expects colors ranging from -1 to 1
      y_batch = np.array([labels for path, labels in batch_paths_and_classes], dtype=np.int32)
      return X_batch, y_batch
  
  X_batch, y_batch = prepare_batch(MNIST_paths_and_classes_train, batch_size=4)
  </code></pre>
  
  <p>X_batch = (4, 299, 299)
  y_batch = (4,)</p>
  
  <pre><code>  X_test, y_test = prepare_batch(MNIST_paths_and_classes_test, batch_size=len(MNIST_paths_and_classes_test))
  </code></pre>
  
  <p>X_test = (12000, 299, 299)</p>
  
  <p>Error in this section:</p>
  
  <p>ValueError: Cannot feed value of shape (40, 299, 299) for Tensor 'X:0', which has shape '(?, 299, 299, 3)'</p>
  
  <pre><code>n_epochs = 10
  batch_size = 40
  n_iterations_per_epoch = len(MNIST_paths_and_classes_train) // batch_size
  
  with tf.Session() as sess:
      init.run()
      inception_saver.restore(sess, INCEPTION_V3_CHECKPOINT_PATH)
  
      for epoch in range(n_epochs):
          print("Epoch", epoch, end="")
          for iteration in range(n_iterations_per_epoch):
              print(".", end="")
              X_batch, y_batch = prepare_batch(MNIST_paths_and_classes_train, batch_size)
              sess.run(training_op, feed_dict={X: X_batch, y: y_batch, training: True})
  
          acc_train = accuracy.eval(feed_dict={X: X_batch, y: y_batch})
          print("  Train accuracy:", acc_train)
  
          save_path = saver.save(sess, "./my_MNIST_model")
  </code></pre>