[英]Tensorflow - ValueError: Shape must be rank 1 but is rank 0 for 'ParseExample/ParseExample'
I have a .tfrecords
file of the Ubuntu Dialog Corpus. 我有一个Ubuntu Dialog Corpus的.tfrecords
文件。 I am trying to read in the whole dataset so that I can split the contexts and utterances into batches. 我试图读取整个数据集,以便我可以将上下文和话语分成批次。 Using tf.parse_single_example
I was able to read in a single example. 使用tf.parse_single_example
我能够读到一个例子。 I tried using tf.parse_example
but I get the following error 我尝试使用tf.parse_example
但是我收到以下错误
ValueError: Shape must be rank 1 but is rank 0 for 'ParseExample/ParseExample' (op: 'ParseExample') with input shapes: [], [0], [], [], [], [], [], [0], [0], [0], [0], [0].
I am not sure what to make of it. 我不知道该怎么做。 The code I used to get to the error - 我用来获取错误的代码 -
import tensorflow as tf
TRAIN_FILE_TFREC = 'data/train.tfrecords'
filename_queue = tf.train.string_input_producer([TRAIN_FILE_TFREC])
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_example(serialized_example,
features = {
"context" : tf.FixedLenFeature([160], tf.int64),
"context_len" : tf.FixedLenFeature([1], tf.int64),
"utterance" : tf.FixedLenFeature([80], tf.int64),
"utterance_len" : tf.FixedLenFeature([1], tf.int64),
"label" : tf.FixedLenFeature([1], tf.int64)
})
Any ideas 有任何想法吗
to use tf.parse_example you need to first batch the examples: 要使用tf.parse_example,您需要先批量示例:
batch = tf.train.batch([serialized_example], num_examples, capacity=num_examples)
parsed_examples = tf.parse_example(batch, feature_spec)
I had a similar problem just now. 我刚才有类似的问题。 Try putting brackets around the serialized_example to turn it into a list: 尝试在serialized_example周围放置括号以将其转换为列表:
features = tf.parse_example([serialized_example],
features = {
"context" : tf.FixedLenFeature([160], tf.int64),
"context_len" : tf.FixedLenFeature([1], tf.int64),
"utterance" : tf.FixedLenFeature([80], tf.int64),
"utterance_len" : tf.FixedLenFeature([1], tf.int64),
"label" : tf.FixedLenFeature([1], tf.int64)
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.