All shapes must be fully defined: [TensorShape([Dimension(299), Dimension(299), Dimension(3)])
he data you want to batch must have pre-defined shape, in you case, tensor image
doesn't, you need to specify the shape with image.set_shape
or tf.image.resize_images
1. 在读入数据时,采用了如下代码形式
- def read_image(image_path):
- """the image_path is the path of single image"""
- file_contents = tf.read_file(input_queue[0])
- image_data = tf.image.decode_jpeg(file_contents, channels=3)
- label = input_queue[1]
- image_id_wgb = input_queue[2]
- return image_data, label, image_id_wgb
- input_queue = tf.train.slice_input_producer([training_image_path_total,training_labels_total, training_image_id_total], shuffle=True)
- '''''the content of input_queue is the properties of one image, which includes a image_path(input_queue[0]), label(input_queue[1]), and image_id(input_queue[2]) of one image'''
- training_image_data, training_label, training_image_id= read_image(image_path = input_queue)
- training_image_batch, training_label_batch,training_image_id_batch = tf.train.shuffle_batch([training_image_data, training_label, training_image_id],batch_size=64,num_threads = 8, min_after_dequeue =101,capacity = 1000)
- ValueError: All shapes must be fully defined: [TensorShape([Dimension(None), Dimension(None), Dimension(3)]), TensorShape([]), TensorShape([])]
- 2. 解决办法</p>
- <在 tf.train.shuffle_batch 前加入了下面一个命令,才解决了.原因不知为何
- training_image_data = tf.image.resize_images(training_image_data, [size, size])