Google.protobuf.text_format.parseerror在使用Python实例化张量



我在Ubuntu 16.04上。我有:Python 2.7.12,Python 3.5.2,Tensorflow 1.2.0-RC1,Protobuf 3.3.0。

我想遵循本教程。

,但我认为通过此测试可以更简洁地证明我的问题:

import tensorflow as tf
regressor = tf.contrib.learn.LinearRegressor(feature_columns=[])

我无法实例化回归器。我得到(结尾完整的追溯(:

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

在教程的[21]中也是如此。Python2和Python3也是如此。如果我使用线性classifier而不是线性重构器。

也是如此。

对我做错了什么的想法?

追溯(最近的最新电话(:

文件" test.py",第2行,在 回归= tf.contrib.learn.linearRegressor(feature_columns = [](

文件 "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/lazy_loader.py", 第53行, getAttr 模块= self._load((

文件 "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/lazy_loader.py", 第42行,_负载 模块= ementlib.import_module(self。 name (

file"/usr/lib/python2.7/importlib/ init .py",第37行,in import_module 导入(名称(

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

文件 "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/image/pintect_s> init .py", 第40行,在 来自tensorflow.contrib.image.python.ops.single_image_random_dot_stereogramss 导入single_image_random_dot_steremonics

文件 "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/image/python/python/single_image_random_dot_stereograms.py", 第26行,在 " _single_image_random_dot_steregrams.so"(

文件 "/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(包装器,模块。 dict (

文件",第248行,

文件",第114行,在_initopdeflibrary

文件 "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", 第481行,合并 Decitiondor_pool = distriptor_pool(

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

文件 "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", 第568行,在Mergelines中 self._parseormerge(行,消息(

文件 "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", 第583行,在_Parseormerge self._mergefield(tokenizer,消息(

文件 "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", 第684行,在_Mergefield 合并(令牌,消息,字段(

文件 "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", 第773行,在_ -Mergemessagefield self._mergefield(tokenizer,sub_message(

文件 "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", 第684行,在_Mergefield 合并(令牌,消息,字段(

文件 "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", 第773行,在_ -Mergemessagefield self._mergefield(tokenizer,sub_message(

文件 "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", 第684行,在_Mergefield 合并(令牌,消息,字段(

文件 "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", 第773行,在_ -Mergemessagefield self._mergefield(tokenizer,sub_message(

文件 "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", 第652行,在_Mergefield (Message_descriptor.full_name,名称(

解决方案

将您的数字环境设置更改为使用期间(。(而不是逗号(,(作为十进制分离器。

说明

在Google protobuf 实现中,使用区域依赖性功能将float转换为FloatToBuffer()中的字符串。

自动提取插件库的信息时,这将成为一个问题。

在您的情况下,这是序列

eye_separation: float = 2.5

在offset 0xa3b4 in emphasized _single_image_random_dot_stereograms.so

被喂入使用FloatToBuffer()的解析器后,这出来了:

attr {n'
  name: "eye_separation"n'
  type: "float"n'
  default_value {n'
    f: 2,5n'
  }n'
}n'

,然后默认值中的,混淆了令牌(在google/protobuf/text_format.py上(,并认为5是一个单独的字段。

错误报告在GitHub上进行了,因此希望很快就会解决。

对我来说,运行export LC_ALL=C工作。

//erik

它是解决问题的解决方案:

import _locale
_locale.setlocale(_locale.LC_NUMERIC, 'en_US.UTF-8')

python3.6,freebsd11

最新更新