一次读取tfrecod文件与tfrecord中的样本数量

当使用tensorflow训练时候,由于生成tfrecord为多个文件,该怎么办那?可以参考如下代码:

tfrecord_file_path = '/train/*.tfrecords’#train是存放tfrecord的文件夹
filename_queue = tf.train.string_input_producer(
                              tf.train.match_filenames_once(tfrecord_file_path),
                              shuffle=True, num_epochs=None) #None表示没哟限制
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)   #返回文件名和文件
features = tf.parse_single_example(serialized_example,
                                       features={XXXXXXX})  #取出XXXXXXX

 

在用tensorflow进行模型训练时,一般都会保存为tfrecord格式的数据,有时候会想查看该tfrecord格式的数据样本多少个。该怎么办那?可以参考如下代码:

    import tensorflow as tf
     
    tf_records_filenames = 'xxx.tfrecords'
    c = 0
    for record in tf.python_io.tf_record_iterator(fn):
       c += 1 
    print c

参考:

  1. https://blog.csdn.net/CSDNbaiduyun/article/details/81537837
  2. https://blog.csdn.net/chanbo8205/article/details/85703719
  3. https://blog.csdn.net/b876144622/article/details/79962786
  4. https://blog.csdn.net/weixin_42499236/article/details/83998139
  5. https://blog.csdn.net/chaipp0607/article/details/72960028
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值