fdeloche
fdeloche

Reputation: 91

Tensorflow : FixedLenFeature Number of bytes values != expected

I try to load examples from a tfrecords file. I have a reader function like :

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

I've just followed https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/how_tos/reading_data/fully_connected_reader.py

But then

example_features = read_record(filename_queue)
values = sess.run({"features":example_features})

stops with the following error :

InvalidArgumentError: Name: , Key: feature, Index: 0. Number of bytes values != expected. Values size: 4096 but output shape: [] Caused by op u'ParseSingleExample/ParseExample/ParseExample'

What is wrong (I know I can mention the actual size but I don't want this) ?

Upvotes: 0

Views: 2833

Answers (1)

fdeloche
fdeloche

Reputation: 91

Ok, I've found myself. The problem is during writing :

I defined an example with :

example = tf.train.Example(features=tf.train.Features(feature={
                'feature' : tf.train.Feature(bytes_list=tf.train.BytesList(
                    value=value))}))

but I've should have used rather

example = tf.train.Example(features=tf.train.Features(feature={
                'feature' : tf.train.Feature(bytes_list=tf.train.BytesList(
                    value=[value]))}))

Upvotes: 6

Related Questions