blei-lab / edward

A probabilistic programming language in TensorFlow. Deep generative models, variational inference.
http://edwardlib.org
Other
4.83k stars 760 forks source link

Import error with tensorflow r1.8 #893

Open xiangze opened 6 years ago

xiangze commented 6 years ago

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?

IanQS commented 6 years ago

891 and #882

The set_shapes_for_outputs function seems to have been deprecated as of 1.7

larsr commented 6 years ago

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)

devinbostIL commented 6 years ago

Why has this not been turned into a pull request?

CMoebus commented 6 years ago

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'
stephenhky commented 6 years ago

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
boyali commented 6 years ago

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

image357 commented 6 years ago

I got the same error.

Tensorflow: 1.11.0 Edward: 1.3.5

qw924 commented 5 years ago

I got the same issue.

edward-1.3.5 tensorflow-1.11.0

VoroninDA commented 5 years ago

tf version 1.12.0 edward version 1.3.5

Getting the same issue.

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

oduerr commented 5 years ago

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

image357 commented 5 years ago

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

ginward commented 5 years ago

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