zoukankan      html  css  js  c++  java
  • 制作 tensorflow record 文件

     http://warmspringwinds.github.io/tensorflow/tf-slim/2016/12/21/tfrecords-guide/

    https://medium.com/mostly-ai/tensorflow-records-what-they-are-and-how-to-use-them-c46bc4bbb564

    https://medium.com/ymedialabs-innovation/how-to-use-tfrecord-with-datasets-and-iterators-in-tensorflow-with-code-samples-ffee57d298af

    http://leix.me/2017/01/09/tensorflow-practical-guides/#非序列数据

    tensorflow 的 record 文件生成

    FastGFile 这个功能已被弃用。它将在未来版本中删除。更新说明:使用tf.gfile.GFile。

     对于tf.read_file 和 tf.write_file 两个操作,是tensorflow 图体系中的正常节点.

     对于 tf.gfile 更像是本地的文件及其文件夹操作。

     看看,如何解析tensorflow records 不难发现,特征的数值使用一个列表来装,列表不能嵌套,其元素是int,float,string 三种类型!

    解析的时候,若按照固定长度的特征解析,shape参数的值需要与写入的特征的长度一致,若灭有值的话可以设置默认值,但就是不能长度不一致

    否则需要使用变长特征来解析。

     1 f1=tf.train.Feature(int64_list=tf.train.Int64List(value=[13,12]))
     2 f2=tf.train.Feature(int64_list=tf.train.Int64List(value=[12]))
     3 f3=tf.train.Feature(bytes_list=tf.train.BytesList(value=[b"abcde",b"abcde"]))
     4 
     5 example = tf.train.Example(features=_make_named_features({"f1":f1,"f2":f2,"f3":f3}))
     6 
     7 #f1=tf.train.Feature(int64_list=tf.train.Int64List(value=[]))
     8 f2=tf.train.Feature(int64_list=tf.train.Int64List(value=[22]))
     9 f3=tf.train.Feature(bytes_list=tf.train.BytesList(value=[b"cde",b"abcde"]))
    10 
    11 example2 = tf.train.Example(features=_make_named_features({"f2":f2,"f3":f3}))
    12 
    13 _features = {
    14     'f1': tf.FixedLenFeature([2], dtype=tf.int64,default_value=[3,5]),
    15     'f2': tf.FixedLenFeature([1], dtype=tf.int64),
    16     'f3': tf.FixedLenFeature([2], dtype=tf.string),
    17 }

    f1=tf.train.Feature(int64_list=tf.train.Int64List(value=[12]))
    f2=tf.train.Feature(int64_list=tf.train.Int64List(value=[34]))
    f3=tf.train.Feature(bytes_list=tf.train.BytesList(value=[b"abcde",b"abcde"]))

    example = tf.train.Example(features=_make_named_features({"f1":f1,"f2":f2,"f3":f3}))

    f1=tf.train.Feature(int64_list=tf.train.Int64List(value=[45,12]))
    f2=tf.train.Feature(int64_list=tf.train.Int64List(value=[34]))
    f3=tf.train.Feature(bytes_list=tf.train.BytesList(value=[b"cde",b"abcde"]))

    example2 = tf.train.Example(features=_make_named_features({"f1":f1,"f2":f2,"f3":f3}))

    _features = {
    'f1': tf.VarLenFeature(dtype=tf.int64),
    'f2': tf.FixedLenFeature([1], dtype=tf.int64),
    'f3': tf.FixedLenFeature([2], dtype=tf.string),
    }

  • 相关阅读:
    mysq 日期相减
    说说时间观与时间管理——北漂18年(71)
    ionic之切换开关
    ionic之单选框
    SELECT ... LOCK IN SHARE MODE和SELECT ... FOR UPDATE locks在RR模式下可以看到最新的记录
    14.5.2.3 Consistent Nonlocking Reads 一致性非锁定读
    14.5.2.2 autocommit, Commit, and Rollback
    14.5.2 事务隔离级别
    对于唯一索引使用唯一条件搜索, InnoDB 只锁定找到的index record,不是它之前的区间
    mysql explain 解释
  • 原文地址:https://www.cnblogs.com/wdmx/p/10142735.html
Copyright © 2011-2022 走看看