阅读(4524) (1)

TensorFlow函数:tf.VarLenFeature

2018-04-18 09:51:39 更新

tf.VarLenFeature函数

VarLenFeature类

定义在:tensorflow/python/ops/parsing_ops.py.

用于解析可变长度输入功能的配置.

函数字段:

  • dtype:输入的数据类型.

属性

dtype

字段编号0的别名

方法

__new__

__new__(
    _cls,
    dtype
)

创建VarLenFeature(dtype)的新实例.


  • Ob的例子里面,有int64和int64list,看一下代码,他就是分成,单个值和数组 两种情况而已。
 def bytes_feature(value):
 return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
 def bytes_list_feature(value):
 return tf.train.Feature(bytes_list=tf.train.BytesList(value=value))
  • 所以,在使用的时候,创建record的时候,比如ob里面,一张图片里面可以有多个bbox,每个bbox都有其对象的lable,这些,显然是数组。
 'image/height': dataset_util.int64_feature(height),
 'image/width': dataset_util.int64_feature(width),
 'image/filename': dataset_util.bytes_feature(
 data['filename'].encode('utf8')),
 'image/encoded': dataset_util.bytes_feature(encoded_jpg),
 'image/format': dataset_util.bytes_feature('jpeg'.encode('utf8')),
 
 'image/object/bbox/xmin': dataset_util.float_list_feature(xmin),
 'image/object/bbox/xmax': dataset_util.float_list_feature(xmax),
 'image/object/bbox/ymin': dataset_util.float_list_feature(ymin),
 'image/object/bbox/ymax': dataset_util.float_list_feature(ymax),
 'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
 'image/object/class/label': dataset_util.int64_list_feature(classes),
  • 在用slim读取record进行处理的时候,对于原来是list写进record的字段,应该用tf.VarLenFeature来萃取。
 'image/object/bbox/xmin': tf.VarLenFeature(tf.float32),