tensorflow:使用tfrecords时的注意事项

  • 确保 string_input_producer 中的文件名字是正确的。

  • string_input_producer(file_names, num_epochs=100000, shuffle=True) 当指定 num_epochs 时,在初始化模型参数的时候,一定要 记得 tf.local_variables_initializer().run() , 因为 tf 会将 num_epoch 作为 local variable。 否则的话,会报错 Attempting to use uninitialized value ReadData/input_producer/limit_epochs/epochs

  • 解码 tfrecords 时的类型一定要和制作 tfreords 时的类型一致:

    这个问题主要出现在 bytestring 上,在保存图片数据时候,我们通常会

    1. 将图片 .tostring() 转成 bytestring
    2. 制作 tfrecords
    3. 然后在解码的时候,我们会用 decode_raw 将bytestring 解码出来。
    4. decode_row(bytes, out_type)

    这里要注意的是,out_type一定要和 .tostring() 之前的数据类型一致。

  • Cannot create initializer for non-floating point type.
    if you encounted this error, you shoud check whether the image casted to float32 dtype

  • 需要 batch_size 个样本,但是获得 0 个: 这种问题应该检查

    • string input producer 中的文件名是否正确
    • 有没有 start_queue_runner
    • 有没有不小心将 执行 enqueue_op 的线程给关了
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值