This question expands somewhat. How can I use values ββread from TFRecords as arguments to tf.reshape?
I transferred my images to a specific form with the following code:
height = tf.cast(features['height'],tf.int32) width = tf.cast(features['width'],tf.int32) image = tf.reshape(image,tf.pack([height, width, 3]))
In cifar10_input code, the image is then distorted as follows: IMAGE_SIZE = 32:
height = IMAGE_SIZE width = IMAGE_SIZE distorted_image = tf.random_crop(image, [height, width, 3])
However, for my purposes, I now do not need to make a random crop. Thus, I replaced this line as follows:
distorted_image = image
When I do this, it throws the following error:
Traceback (most recent call last): File "cnn_train.py", line 128, in <module> tf.app.run() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/default/_app.py", line 30, in run sys.exit(main(sys.argv)) File "cnn_train.py", line 124, in main train() File "cnn_train.py", line 56, in train images, labels = cnn.distorted_inputs() File "/home/samuelchin/tensorflow/my_code/CNN/cnn.py", line 123, in distorted_inputs batch_size=BATCH_SIZE) File "/home/samuelchin/tensorflow/my_code/CNN/cnn_input.py", line 128, in distorted_inputs min_queue_examples, batch_size) File "/home/samuelchin/tensorflow/my_code/CNN/cnn_input.py", line 70, in _generate_image_and_label_batch min_after_dequeue=min_queue_examples) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/input.py", line 494, in shuffle_batch dtypes=types, shapes=shapes) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/data_flow_ops.py", line 404, in __init__ shapes = _as_shape_list(shapes, dtypes) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/data_flow_ops.py", line 70, in _as_shape_list raise ValueError("All shapes must be fully defined: %s" % shapes) ValueError: All shapes must be fully defined: [TensorShape([Dimension(None), Dimension(None), Dimension(None)]), TensorShape([])]
I have 2 questions:
- Why does this cause an error when I do not do tf.random_crop? It seems to me that tf.random_crop returns something that is completely different from the image.
- Just sets IMAGE_SIZE to the size I want for a good solution? For example, if the images are 32 x 32, and I want to crop them to 24 x 24, I set IMAGE_SIZE = 24. Now, since I want it to be 32 x 32, should I just set IMAGE_SIZE = 32?