[英]TensorFlow Recommenders - ValueError: Shape must be rank 2 but is rank 3
[英]Tensorflow - ValueError: Shape must be rank 1 but is rank 0 for 'ParseExample/ParseExample'
我有一个Ubuntu Dialog Corpus的.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)
})
有任何想法吗
要使用tf.parse_example,您需要先批量示例:
batch = tf.train.batch([serialized_example], num_examples, capacity=num_examples)
parsed_examples = tf.parse_example(batch, feature_spec)
我刚才有类似的问题。 尝试在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.