Reputation: 668
I tried to get following program to work: https://github.com/mattdangerw/keras-text-generation
In my CMD (Windows 10) I entered:
python train.py
I got following error:
Using TensorFlow backend.
Loading data...
corpus length: 1223047
vocab size: 41
x.shape: (44608, 50)
y.shape: (44608, 50, 1)
x_val.shape: (4288, 50)
y_val.shape: (4288, 50, 1)
Data load time 0.958162784576416
Building model...
Traceback (most recent call last):
File "train.py", line 42, in <module>
main()
File "train.py", line 37, in main
model.train(**vars(args))
File "D:\IoT\Aufgabe4\task3\keras-text-generation\model.py", line 135, in train
self._build_models(batch_size, embedding_size, rnn_size, num_layers)
File "D:\IoT\Aufgabe4\task3\keras-text-generation\model.py", line 92, in _build_models
model = Sequential()
File "C:\Users\Michael\Anaconda3\lib\site-packages\keras\engine\sequential.py", line 87, in __init__
super(Sequential, self).__init__(name=name)
File "C:\Users\Michael\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "C:\Users\Michael\Anaconda3\lib\site-packages\keras\engine\network.py", line 96, in __init__
self._init_subclassed_network(**kwargs)
File "C:\Users\Michael\Anaconda3\lib\site-packages\keras\engine\network.py", line 294, in _init_subclassed_network
self._base_init(name=name)
File "C:\Users\Michael\Anaconda3\lib\site-packages\keras\engine\network.py", line 109, in _base_init
name = prefix + '_' + str(K.get_uid(prefix))
File "C:\Users\Michael\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 74, in get_uid
graph = tf.get_default_graph()
AttributeError: module 'tensorflow' has no attribute 'get_default_graph'
Python Version:
python --version
Python 3.7.3
Keras Version:
python -c "import keras; print(keras.__version__)"
Using TensorFlow backend.
2.2.4
Tensorflow Version:
python -c "import tensorflow as tf; print(tf.__version__)"
2.0.0-alpha0
I also installed pip and with pip I have also installed colorama, which is needed.
How to fix it? A friend tested the same program and performed the same installation and configuration, but without any error messages. I think it`s a problem with tensorflow. Am I right?
Upvotes: 1
Views: 2394
Reputation: 56347
Keras does not currently support TensorFlow 2.0, since it is still an alpha version. You either need to use tf.keras
, or downgrade TensorFlow to 1.13 in order to use the official keras
package.
Upvotes: 1
Reputation: 316
This is a known Tensorflow/Keras bug, read more here:
https://github.com/keras-team/keras/issues/12379
Solution as per link (same as in comment by @Vishal):
I changed the imports from keras.something.something
to tensorflow.keras.something
and the issue seemed to have gone away. Putting it here for others to benefit.
Upvotes: 0