edward
edward copied to clipboard
Import error with tensorflow r1.8
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?
#891 and #882
The set_shapes_for_outputs
function seems to have been deprecated as of 1.7
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)
Why has this not been turned into a pull request?
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)
c:\users\claus\src\edward\edward_init_.py in
c:\users\claus\src\edward\edward\criticisms_init_.py in
c:\users\claus\src\edward\edward\criticisms\evaluate.py in
11 with_binary_averaging
12
c:\users\claus\src\edward\edward\util_init_.py in
c:\users\claus\src\edward\edward\util\random_variables.py in
ImportError: cannot import name 'set_shapes_for_outputs'
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
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
I got the same error.
Tensorflow: 1.11.0 Edward: 1.3.5
I got the same issue.
edward-1.3.5 tensorflow-1.11.0
tf version 1.12.0 edward version 1.3.5
Getting the same issue.
quick fix was to use pipenv install 'tensorflow<=1.7.*'
Is there any other quick fix not requiring to downgrade TF? Background: I want to use it with colab notebooks.
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
Same error. Solved by downgrading tensorflow to 1.7.0.
pip install 'tensorflow==1.7.0' --force-reinstall