Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import error with tensorflow r1.8 #893

Open
xiangze opened this issue May 10, 2018 · 12 comments
Open

Import error with tensorflow r1.8 #893

xiangze opened this issue May 10, 2018 · 12 comments

Comments

@xiangze
Copy link

xiangze commented May 10, 2018

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
Copy link

IanQS commented May 11, 2018

#891 and #882

The set_shapes_for_outputs function seems to have been deprecated as of 1.7

@larsr
Copy link

larsr commented May 14, 2018

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
Copy link

Why has this not been turned into a pull request?

@CMoebus
Copy link

CMoebus commented May 22, 2018

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
Copy link

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
Copy link

boyali commented Jun 24, 2018

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
Copy link

image357 commented Oct 4, 2018

I got the same error.

Tensorflow: 1.11.0
Edward: 1.3.5

@qw924
Copy link

qw924 commented Nov 1, 2018

I got the same issue.

edward-1.3.5
tensorflow-1.11.0

@VoroninDA
Copy link

VoroninDA commented Dec 12, 2018

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
Copy link

oduerr commented Jan 3, 2019

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

@image357
Copy link

image357 commented Jan 3, 2019

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
Copy link

ginward commented May 31, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests