4

In attempting to run the following in PyCharm 2017.3.1:

with open('../data/UrbanSound8K/retrained_graph.pb', 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    tf.import_graph_def(graph_def, name='')

I receive the following:

/anaconda/bin/python3 /Users/PycharmProjects/UrbanSound/src/recognize_sound.py
Traceback (most recent call last):
  File "/Users/PycharmProjects/UrbanSound/src/recognize_sound.py", line 12, in <module>
    graph_def = tf.GraphDef()
AttributeError: module 'tensorflow' has no attribute 'GraphDef'

Here is some environment information:

(tensorflow) $ python3 -c 'import tensorflow as tf; print(tf.__version__)'
1.4.0
(tensorflow) $ python -V
Python 3.6.2

Thank you in advance for your help.

4
  • 1
    Resolved: I corrected my virtualenv to point to tensorflow. Commented Dec 22, 2017 at 17:24
  • 1
    Which version of TF is supposed to support a public interface for GraphDef? Commented Dec 22, 2017 at 17:25
  • 1
    @B33l238u8 could you please explain how you corrected your virtualenv to point to tensorflow? I'm having the same problem. Thanks in advance. Commented Mar 13, 2019 at 22:11
  • You ran python3 -c ... for tf version, but you ran python -V for your python version, is python3 set as 3.6.2 (same as python) ? Commented Oct 3, 2019 at 11:16

3 Answers 3

1

I resolved it using

python36 -m pip install tensorflow-gpu==1.14

Sign up to request clarification or add additional context in comments.

2 Comments

Collecting tensorflow-gpu==1.14 ERROR: Could not find a version that satisfies the requirement tensorflow-gpu==1.14 (from versions: none) ERROR: No matching distribution found for tensorflow-gpu==1.14 I got this error.
I resolved it using python3 -m pip install tensorflow==1.14
1

use "tf.compat.v1.GraphDef()" instead if you are using tensorflow 2.0

Comments

1

disable V2 behavior

import tensorflow.compat.v1 as tf 
tf.disable_v2_behavior()

or use this tf.compat.v1.GraphDef()

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.