admin管理员组

文章数量:1650765

模型加载TFRecords文件时一直报这个错误。
tensorflow.python.framework.errors_impl.InvalidArgumentError: Feature: feature (data type: string) i
提示的是feature对应的数据的类型不对,原来是由于生成TFRecords文件指定的key跟读取时的key不同导致的,好吧,那个s被我吃了,细节决定成败。

# 生成文件时的key是features
example = tf.train.Example(features=tf.train.Features(feature={
    "label": tf.train.Feature(int64_list=tf.train.Int64List(value=[click])),
    "features": tf.train.Feature(bytes_list=tf.train.BytesList(value=[feature]))
}))
# 读取文件时使用的key也应该是features,而不是feature. 
features = {
    'label': tf.FixedLenFeature([], tf.int64),
    'feature': tf.FixedLenFeature([], tf.string)
}

本文标签: featureInvalidArgumentErrorDatarequired