使用Python实例化TensorFlow模型时的google.protobuf.text_format.ParseError

N T*_*N T 5 python tensorflow

我在Ubuntu 16.04上.我有:Python 2.7.12,Python 3.5.2,tensorflow 1.2.0-rc1,protobuf 3.3.0.

我想要学习本教程.

但我认为我的问题可以用这个test.py更简洁地证明:

import tensorflow as tf
regressor = tf.contrib.learn.LinearRegressor(feature_columns=[])
Run Code Online (Sandbox Code Playgroud)

我无法实例化回归量.我得到(最后完整的Traceback):

google.protobuf.text_format.ParseError:48:12:消息类型"tensorflow.AttrValue"没有名为"5"的字段.

同样在本教程的[21]中.python2和python3也是如此.如果我使用LinearClassifier而不是LinearRegressor,也是如此.

关于我做错了什么的任何想法?

Traceback(最近一次调用最后一次):

文件"test.py",第2行,在regressor中= tf.contrib.learn.LinearRegressor(feature_columns = [])

getattr module = self._load()中输入文件"/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/lazy_loader.py",第53行

文件"/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/lazy_loader.py",第42行,在模块_load = importlib.import_module(个体.)

文件"/usr/lib/python2.7/importlib/ 初始化 py"为37行,在import_module 进口(名称)

文件"/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/ init .py",第35行,来自tensorflow.contrib导入图片

文件"/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/image/ 初始化 py"为40行,从tensorflow.contrib.image.python.ops.single_image_random_dot_stereograms进口single_image_random_dot_stereograms

在"_single_image_random_dot_stereograms.so"中输入文件"/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/image/python/ops/single_image_random_dot_stereograms.py",第26行))

文件"/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/util/loader.py",第55行,在load_op_library中ret = load_library.load_op_library(path)

文件"/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/load_library.py",线84,在load_op_library EXEC(包装纸,模块.字典)

文件"",第248行,in

在_InitOpDefLibrary中的文件"",第114行

文件"/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py",第481行,在Merge descriptor_pool = descriptor_pool中)

文件"/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py",第535行,在MergeLines中返回parser.MergeLines(行,消息)

MergeLines中的文件"/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py",第568行,self._ParseOrMerge(行,消息)

在_ParseOrMerge self._MergeField(tokenizer,message)中输入文件"/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py",第583行

在_MergeField合并(tokenizer,message,field)中输入文件"/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py",第684行

在_MergeMes​​sageField self._MergeField(tokenizer,sub_message)中输入文件"/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py",第773行

在_MergeField合并(tokenizer,message,field)中输入文件"/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py",第684行

在_MergeMes​​sageField self._MergeField(tokenizer,sub_message)中输入文件"/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py",第773行

在_MergeField合并(tokenizer,message,field)中输入文件"/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py",第684行

在_MergeMes​​sageField self._MergeField(tokenizer,sub_message)中输入文件"/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py",第773行

文件"/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py",第652行,在_MergeField中(message_descriptor.full_name,name))

Max*_*ler 3

解决方案

更改数字区域设置以使用句点(.) 而不是逗号 (,) 作为小数分隔符。

解释

在 Google protobuf实现中,使用与语言环境相关的函数将 float 转换为FloatToBuffer().

当自动从插件库中提取信息时,这会成为一个问题。

在你的情况下,这是序列

eye_separation: float = 2.5
Run Code Online (Sandbox Code Playgroud)

在偏移量0xa3b4 处emphasized _single_image_random_dot_stereograms.so

在被输入到使用 的解析器之后FloatToBuffer(),结果如下:

attr {\n'
  name: "eye_separation"\n'
  type: "float"\n'
  default_value {\n'
    f: 2,5\n'
  }\n'
}\n'
Run Code Online (Sandbox Code Playgroud)

然后分词器 (at ) 会对默认值中的google/protobuf/text_format.py感到困惑,并认为这是一个单独的字段。,5

GitHub上已发布错误报告,因此该问题有望很快得到修复。