【发布时间】:2018-02-10 03:15:36
【问题描述】:
我有一个 Ubuntu 对话语料库的 .tfrecords 文件。我正在尝试读取整个数据集,以便可以将上下文和话语分成批次。使用tf.parse_single_example 我能够阅读一个示例。我尝试使用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].
我不知道该怎么做。我用来解决错误的代码 -
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)
})
任何想法
【问题讨论】:
-
您需要提供更多详细信息,最好是展示问题的小型、独立的示例。您说
parse_single_example有效,但您的代码使用parse_single_example。你能给出给出错误的准确代码吗? -
@PeterHawkins 更改了代码。不小心输入了
parse_single_example而不是parse_example
标签: python tensorflow