Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tensorflow:FixedLenFeature字节数值!=预期_Python_Arrays_File Io_Tensorflow - Fatal编程技术网

Python Tensorflow:FixedLenFeature字节数值!=预期

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 =

我尝试从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 = 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]))}))