简体   繁体   中英

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))

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
_________________________________________________________________

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 Retin.net.

!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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM