How can I use values read from TFRecords as arguments to tf.reshape?
<pre class="lang-py prettyprint-override"><code>def read_and_decode(filename_queue):
  reader = tf.TFRecordReader()
  _, serialized_example = reader.read(filename_queue)
  features = tf.parse_single_example(
      serialized_example,
      # Defaults are not specified since both keys are required.
      features={
          'image_raw': tf.FixedLenFeature([], tf.string),
          'label': tf.FixedLenFeature([], tf.int64),
          'height': tf.FixedLenFeature([], tf.int64),
          'width': tf.FixedLenFeature([], tf.int64),
          'depth': tf.FixedLenFeature([], tf.int64)
      })
  # height = tf.cast(features['height'],tf.int32)
  image = tf.decode_raw(features['image_raw'], tf.uint8)
  image = tf.reshape(image,[32, 32, 3])
  image = tf.cast(image,tf.float32)
  label = tf.cast(features['label'], tf.int32)
  return image, label
</code></pre>

<p>I'm using a TFRecord to store all my data. The function read_and_decode is from the TFRecords example provided by TensorFlow. Currently I reshape by having predefined values:</p>

<pre class="lang-py prettyprint-override"><code>image = tf.reshape(image,[32, 32, 3])
</code></pre>

<p>However, the data that I will be using now is of different dimensions. For example, I could have an image that is [40, 30, 3] (scaling this is not an option as I don't want it to be warped). I would like to read in data of different dimensions and use random_crop in the data augmentation stage to circumvent this problem. What I need is something like the following.</p>

<pre class="lang-py prettyprint-override"><code>height = tf.cast(features['height'], tf.int32)
width = tf.cast(features['width'], tf.int32)
image = tf.reshape(image,[height, width, 3])
</code></pre>

<p>However, I can't seem to find a way to do this. Thanks for your help!</p>

<p>EDIT:</p>

<pre><code>ValueError: All shapes must be fully defined: [TensorShape([Dimension(None), Dimension(None), Dimension(None)]), TensorShape([])]

image = tf.reshape(image, tf.pack([height, width, 3]))
image = tf.reshape(image, [32,32,3])
</code></pre>

<p>The problem is definitely with these 2 lines. The hard coded variables work, but not the one with tf.pack().</p>