Python Tensorflow:FixedLenFeature字节数值!=预期
我尝试从tfrecords文件加载示例。我有一个读卡器功能,如:Python Tensorflow:FixedLenFeature字节数值!=预期,python,arrays,file-io,tensorflow,Python,Arrays,File Io,Tensorflow,我尝试从tfrecords文件加载示例。我有一个读卡器功能,如: def read_record(filename_queue): reader = tf.TFRecordReader() key, record_string = reader.read(filename_queue) features = { "feature": tf.FixedLenFeature([], dtype=tf.string), } ex_dict =
def read_record(filename_queue):
reader = tf.TFRecordReader()
key, record_string = reader.read(filename_queue)
features = {
"feature": tf.FixedLenFeature([], dtype=tf.string),
}
ex_dict = tf.parse_single_example(record_string, features)
ex_feature = tf.decode_raw(ex_dict["feature"], tf.float32)
return ex_feature
我只是跟着
但是
example_features = read_record(filename_queue)
values = sess.run({"features":example_features})
停止时出现以下错误:
InvalidArgumentError:名称:,键:功能,索引:0。字节数值!=预期。值大小:4096,但输出形状:[]
由op u'ParseSingleExample/ParseExample/ParseExample'引起
有什么问题吗(我知道我可以提到实际尺寸,但我不想要这个)?好的,我已经找到了。问题是在写作过程中: 我定义了一个例子:
example = tf.train.Example(features=tf.train.Features(feature={
'feature' : tf.train.Feature(bytes_list=tf.train.BytesList(
value=value))}))
但我本应该用
example = tf.train.Example(features=tf.train.Features(feature={
'feature' : tf.train.Feature(bytes_list=tf.train.BytesList(
value=[value]))}))
好的,我找到我自己了。问题是在写作过程中: 我定义了一个例子:
example = tf.train.Example(features=tf.train.Features(feature={
'feature' : tf.train.Feature(bytes_list=tf.train.BytesList(
value=value))}))
但我本应该用
example = tf.train.Example(features=tf.train.Features(feature={
'feature' : tf.train.Feature(bytes_list=tf.train.BytesList(
value=[value]))}))