emilwallner / Coloring-greyscale-images

Coloring black and white images with deep learning.
MIT License
1.03k stars 227 forks source link

AttributeError: module 'tensorflow' has no attribute 'get_default_graph' #10

Open ahbon123 opened 5 years ago

ahbon123 commented 5 years ago

I get an attribute error, anyone can help? Thanks.

AttributeError                            Traceback (most recent call last)
<ipython-input-15-218ed4947ab4> in <module>()
      1 # Building the neural network
----> 2 model = Sequential()
      3 model.add(InputLayer(input_shape=(None, None, 1)))
      4 model.add(Conv2D(8, (3, 3), activation='relu', padding='same', strides=2))
      5 model.add(Conv2D(8, (3, 3), activation='relu', padding='same'))

/home/x/.local/lib/python3.7/site-packages/keras/engine/sequential.py in __init__(self, layers, name)
     85 
     86     def __init__(self, layers=None, name=None):
---> 87         super(Sequential, self).__init__(name=name)
     88         self._build_input_shape = None
     89 

/home/x/.local/lib/python3.7/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
     89                 warnings.warn('Update your `' + object_name + '` call to the ' +
     90                               'Keras 2 API: ' + signature, stacklevel=2)
---> 91             return func(*args, **kwargs)
     92         wrapper._original_function = func
     93         return wrapper

/home/x/.local/lib/python3.7/site-packages/keras/engine/network.py in __init__(self, *args, **kwargs)
     94         else:
     95             # Subclassed network
---> 96             self._init_subclassed_network(**kwargs)
     97 
     98     def _base_init(self, name=None):

/home/x/.local/lib/python3.7/site-packages/keras/engine/network.py in _init_subclassed_network(self, name)
    292 
    293     def _init_subclassed_network(self, name=None):
--> 294         self._base_init(name=name)
    295         self._is_graph_network = False
    296         self._expects_training_arg = has_arg(self.call, 'training')

/home/x/.local/lib/python3.7/site-packages/keras/engine/network.py in _base_init(self, name)
    107         if not name:
    108             prefix = self.__class__.__name__.lower()
--> 109             name = prefix + '_' + str(K.get_uid(prefix))
    110         self.name = name
    111 

/home/x/.local/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py in get_uid(prefix)
     72     """
     73     global _GRAPH_UID_DICTS
---> 74     graph = tf.get_default_graph()
     75     if graph not in _GRAPH_UID_DICTS:
     76         _GRAPH_UID_DICTS[graph] = defaultdict(int)

AttributeError: module 'tensorflow' has no attribute 'get_default_graph'
codeman008 commented 5 years ago

Have you solved this problem?I am currently studying such a project. May I communicate with you?

ahbon123 commented 5 years ago

Sorry for my later reply. I haven't solve this issue, but sure you can communicate with me.

ajaychaudhary7 commented 4 years ago

change it to :
tf.compat.v1.get_default_graph()

NTaravati commented 3 years ago

Well, actually the issue is that the version is not compatible with Tensorflow 2.x. Running Tensorflow 1.15.0 and Keras 2.3.1. works fine here; just create an additional environment in conda and make sure you install these packages with 'pip install tensorflow-gpu==1.15.0' and 'pip install keras==2.3.1'. to make it work