TensorFlow函數(shù):tf.VarLenFeature

2020-07-16 11:28 更新

tf.VarLenFeature函數(shù)

VarLenFeature類(lèi)

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

用于解析可變長(zhǎng)度輸入功能的配置.

函數(shù)字段:

  • dtype:輸入的數(shù)據(jù)類(lèi)型.

屬性

dtype

字段編號(hào)0的別名

方法

__new__

__new__(
    _cls,
    dtype
)

創(chuàng)建VarLenFeature(dtype)的新實(shí)例.


  • Ob的例子里面,有int64和int64list,看一下代碼,他就是分成,單個(gè)值和數(shù)組 兩種情況而已。
 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))
  • 所以,在使用的時(shí)候,創(chuàng)建record的時(shí)候,比如ob里面,一張圖片里面可以有多個(gè)bbox,每個(gè)bbox都有其對(duì)象的lable,這些,顯然是數(shù)組。
 '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進(jìn)行處理的時(shí)候,對(duì)于原來(lái)是list寫(xiě)進(jìn)record的字段,應(yīng)該用tf.VarLenFeature來(lái)萃取。
 'image/object/bbox/xmin': tf.VarLenFeature(tf.float32),
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)