5
votes

I'm on Ubuntu 16.04. I have: Python 2.7.12, Python 3.5.2, tensorflow 1.2.0-rc1, protobuf 3.3.0.

I want to follow this tutorial.

But I think my problem can be evidenced more succinctly with this test.py:

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

I cannot instantiate regressor. I get (full Traceback at the end):

google.protobuf.text_format.ParseError: 48:12 : Message type "tensorflow.AttrValue" has no field named "5".

Same goes in [21] of the tutorial. Same goes with python2 and python3. Same goes if I use LinearClassifier instead of LinearRegressor.

Any idea about what I am doing very wrong?

Traceback (most recent call last):

File "test.py", line 2, in regressor = tf.contrib.learn.LinearRegressor(feature_columns=[])

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/lazy_loader.py", line 53, in getattr module = self._load()

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/lazy_loader.py", line 42, in _load module = importlib.import_module(self.name)

File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name)

File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/init.py", line 35, in from tensorflow.contrib import image

File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/image/init.py", line 40, in from tensorflow.contrib.image.python.ops.single_image_random_dot_stereograms import single_image_random_dot_stereograms

File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/image/python/ops/single_image_random_dot_stereograms.py", line 26, in "_single_image_random_dot_stereograms.so"))

File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/util/loader.py", line 55, in load_op_library ret = load_library.load_op_library(path)

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/load_library.py", line 84, in load_op_library exec(wrappers, module.dict)

File "", line 248, in

File "", line 114, in _InitOpDefLibrary

File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 481, in Merge descriptor_pool=descriptor_pool)

File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 535, in MergeLines return parser.MergeLines(lines, message)

File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 568, in MergeLines self._ParseOrMerge(lines, message)

File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 583, in _ParseOrMerge self._MergeField(tokenizer, message)

File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 684, in _MergeField merger(tokenizer, message, field)

File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 773, in _MergeMessageField self._MergeField(tokenizer, sub_message)

File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 684, in _MergeField merger(tokenizer, message, field)

File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 773, in _MergeMessageField self._MergeField(tokenizer, sub_message)

File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 684, in _MergeField merger(tokenizer, message, field)

File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 773, in _MergeMessageField self._MergeField(tokenizer, sub_message)

File "/usr/local/lib/python2.7/dist-packages/google/protobuf/text_format.py", line 652, in _MergeField (message_descriptor.full_name, name))

3
I don't think that there is anything you are doing wrong. I can confirm this error with a fresh Tensorflow r1.2 from GitHub build on Ubuntu 17.04 and Python 3.5.3Maximilian Köstler
On Tensorflow r1.1 regressor = tf.contrib.learn.LinearRegressor(feature_columns=[]) asserts because the feature_columns may not be empty, but there is no error with protobuf so it has to be a change from r1.1 to r1.2 that causes this.Maximilian Köstler
Thank you Maximilian for confirming the error. I add that it seems to be working with python3 using the custom binary protobuf pip from package tensorflow.org/versions/r1.2/install/…. (In fact giving AssertionError on my simple example which is the normal behaviour as you remarked.)N T
I have updated my solution to include a workaround suggested by cwhipkey on GitHub. The updated binary protobuf package did not help in my case.Maximilian Köstler

3 Answers

3
votes

Solution

Change your numeric locale settings to use a period (.) instead of a comma (,) as decimal separator.

Explanation

In the Google protobuf implementation, a locale dependent function is used to convert float to strings in FloatToBuffer().

This becomes a problem when information from a plugin library is extracted automatically.

In your case, it is the sequence

eye_separation: float = 2.5

at offset 0xa3b4 in emphasized _single_image_random_dot_stereograms.so

After being fed to the parser which uses FloatToBuffer(), this comes out:

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

and then the tokenizer (at google/protobuf/text_format.py) gets confused by the , in the default value and thinks that 5 is a separate field.

A bug report is live at GitHub and so this will hopefully get fixed, soon.

3
votes

For me, running export LC_ALL=C worked.

//Erik

-1
votes

it's worked solution for it problem:

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

python3.6, freebsd11