遇到的問題與解決辦法(tf.train.shuffle_batch與tf.train.slice_input_producer)
阿新 • • 發佈:2019-01-10
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. 解決辦法
在 tf.train.shuffle_batch 前加入了下面一個命令,才解決了.原因不知為何
training_image_data = tf.image.resize_images(training_image_data, [size, size])