Tensorflow值错误:“ParseExample/ParseExample”的形状必须是等级1,但等级为0

2024-04-26 13:02:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个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].

我不知道该怎么解释。我用来找出错误的代码-

^{pr2}$

有什么想法吗


Tags: 文件数据parseexampleubuntutf错误tfrecords
2条回答

我刚才也有类似的问题。尝试在序列化的_示例周围加上括号,将其转换为一个列表:

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_示例您需要首先批处理示例:

batch = tf.train.batch([serialized_example], num_examples, capacity=num_examples)
parsed_examples = tf.parse_example(batch, feature_spec)

相关问题 更多 >