遇到的问题与解决办法(tf.train.shuffle_batch与tf.train.slice_input_producer)


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])



评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值