'Deeplearning with Python Tensorflow,Keras
I am writing masters thesis about deeplearning and have a problem probably about library.
Below is the error:
AttributeError: module 'tensorflow.compat.v2' has no attribute '__internal__'
Model:
import tensorflow
from tensorflow import keras
from keras import models
from keras import layers
model = models.Sequential()
model.add(layers.Dense(32, input_shape=(784,)))
model.add(layers.Dense(32))
Solution 1:[1]
I think that the problem lies in the way you are importing the modules you need. Try to do this way:
import tensorflow
from tensorflow.keras import models, layers
model = models.Sequential()
model.add(layers.Dense(32, input_shape=(784,)))
model.add(layers.Dense(32))
model.summary()
If you get the summary of your network it means that everything is working fine, otherwise it could me that you haven't installed Tensorflow properly.
For reference this is the summary:
Layer (type) Output Shape Param #
=================================================================
dense (Dense) (None, 32) 25120
_________________________________________________________________
dense_1 (Dense) (None, 32) 1056
=================================================================
Total params: 26,176
Trainable params: 26,176
Non-trainable params: 0
_________________________________________________________________
Solution 2:[2]
most likely is the version of tensorflow you are using You just need to uninstall all keras and tensorflow packages and install the versions supported by Retinanet.
!pip uninstall keras -y !pip uninstall keras-nightly -y !pip uninstall keras-Preprocessing -y !pip uninstall keras-vis -y !pip uninstall tensorflow -y
!pip install tensorflow==2.3.0 !pip install keras==2.4
Just add this to the top of your colab notebook and restart your runtime once its completed and then you are good to go
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Dharman |
Solution 2 | user3302667 |