edward icon indicating copy to clipboard operation
edward copied to clipboard

Import error with tensorflow r1.8

Open xiangze opened this issue 6 years ago • 12 comments

tensorflow r1.8 does not seem to have "set_shapes_for_outputs" and an error occurs when importing edward.

from tensorflow.python.framework.ops import set_shapes_for_outputs in edward/edward/util/random_variables.py https://github.com/blei-lab/edward/blob/master/edward/util/random_variables.py#L15

Just comment out "from tensorflow.python.framework.ops import set_shapes_for_outputs" and following lines does not work. https://github.com/blei-lab/edward/blob/master/edward/util/random_variables.py#L404

How to be implemented this function without set_shapes_for_outputs?

xiangze avatar May 10 '18 18:05 xiangze

#891 and #882

The set_shapes_for_outputs function seems to have been deprecated as of 1.7

IanQS avatar May 11 '18 15:05 IanQS

This is related to issue 882.

I replaced the import line edward/util/random_variables.py#L15 with

from tensorflow.python.framework.ops import set_shape_and_handle_data_for_outputs as set_shapes_for_outputs

as it seems like the function has been renamed here. Not sure if it is necessary to use it, but at least this quickfix makes it possible to use tensorflow 1.8 (I haven't run many tests, just got it to work)

larsr avatar May 14 '18 12:05 larsr

Why has this not been turned into a pull request?

devinbostIL avatar May 17 '18 22:05 devinbostIL

I am new to TF and Edward. I conda/pip installed TF and Edward according the "Get Started" recommendations. Then I ran Jupyter and got this same error:

import matplotlib.pyplot as plt import numpy as np import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello)) C:\Users\claus\Anaconda3\lib\site-packages\h5py_init_.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters b'Hello, TensorFlow!' %matplotlib inline from future import absolute_import from future import division from future import print_function

import edward as ed

from edward.models import Normal

plt.style.use('ggplot')

ImportError Traceback (most recent call last) in () 4 from future import print_function 5 ----> 6 import edward as ed 7 8 from edward.models import Normal

c:\users\claus\src\edward\edward_init_.py in () 3 from future import print_function 4 ----> 5 from edward import criticisms 6 from edward import inferences 7 from edward import models

c:\users\claus\src\edward\edward\criticisms_init_.py in () 5 from future import print_function 6 ----> 7 from edward.criticisms.evaluate import * 8 from edward.criticisms.ppc import * 9 from edward.criticisms.ppc_plots import *

c:\users\claus\src\edward\edward\criticisms\evaluate.py in () 8 9 from edward.models import RandomVariable ---> 10 from edward.util import check_data, get_session, compute_multinomial_mode,
11 with_binary_averaging 12

c:\users\claus\src\edward\edward\util_init_.py in () 8 from edward.util.metrics import * 9 from edward.util.progbar import * ---> 10 from edward.util.random_variables import * 11 from edward.util.tensorflow import * 12

c:\users\claus\src\edward\edward\util\random_variables.py in () 13 from edward.util.graphs import random_variables 14 from tensorflow.core.framework import attr_value_pb2 ---> 15 from tensorflow.python.framework.ops import set_shapes_for_outputs 16 from tensorflow.python.util import compat 17

ImportError: cannot import name 'set_shapes_for_outputs'

CMoebus avatar May 22 '18 16:05 CMoebus

I am having the same issue too. I am running on Python 2.7.12, tensorflow 1.8.0, and I just installed edward 1.14.3. I am running on mac OS X 10.13.4. I type

python -c "import edward"

And then I got the following message:

/Users/stephenhky/anaconda/lib/python2.7/site-packages/h5py/__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/stephenhky/anaconda/lib/python2.7/site-packages/edward/__init__.py", line 5, in <module>
    from edward import criticisms
  File "/Users/stephenhky/anaconda/lib/python2.7/site-packages/edward/criticisms/__init__.py", line 7, in <module>
    from edward.criticisms.evaluate import *
  File "/Users/stephenhky/anaconda/lib/python2.7/site-packages/edward/criticisms/evaluate.py", line 10, in <module>
    from edward.util import check_data, get_session, compute_multinomial_mode, \
  File "/Users/stephenhky/anaconda/lib/python2.7/site-packages/edward/util/__init__.py", line 10, in <module>
    from edward.util.random_variables import *
  File "/Users/stephenhky/anaconda/lib/python2.7/site-packages/edward/util/random_variables.py", line 15, in <module>
    from tensorflow.python.framework.ops import set_shapes_for_outputs
ImportError: cannot import name set_shapes_for_outputs

stephenhky avatar Jun 16 '18 19:06 stephenhky

With lars's solution, the Bayesian Linear regression example gives an error.

reconstruct_sequence_inputs(self, op_def, inputs, attrs) 1801 grouped_inputs.append(inputs[i:i + input_len]) 1802 else: -> 1803 grouped_inputs.append(inputs[i]) 1804 i += input_len

boyali avatar Jun 24 '18 00:06 boyali

I got the same error.

Tensorflow: 1.11.0 Edward: 1.3.5

image357 avatar Oct 04 '18 18:10 image357

I got the same issue.

edward-1.3.5 tensorflow-1.11.0

qw924 avatar Nov 01 '18 23:11 qw924

tf version 1.12.0 edward version 1.3.5

Getting the same issue.

quick fix was to use pipenv install 'tensorflow<=1.7.*'

VoroninDA avatar Dec 12 '18 05:12 VoroninDA

Is there any other quick fix not requiring to downgrade TF? Background: I want to use it with colab notebooks.

oduerr avatar Jan 03 '19 19:01 oduerr

Is there any other quick fix not requiring to downgrade TF? Background: I want to use it with colab notebooks.

I guess you currently should use tensorflow-probability, which contains edward2.

https://github.com/tensorflow/probability/blob/master/tensorflow_probability/python/edward2/Upgrading_From_Edward_To_Edward2.md

image357 avatar Jan 03 '19 20:01 image357

Same error. Solved by downgrading tensorflow to 1.7.0. pip install 'tensorflow==1.7.0' --force-reinstall

ginward avatar May 31 '19 22:05 ginward