module ‘tensorflow.compat.v2.__internal__‘ has no attribute ‘register_clear_session_function‘ 解决方法

from keras.models import Sequential
from keras.layers.core import Dense,Dropout,Activation
from keras.optimizers import SGD,Adam
from keras.utils import np_utils
from keras.datasets import mnist

版本:
tensorflow : 2.5.1
keras: 2.5.0

报错:
module ‘tensorflow.compat.v2.internal’ has no attribute ‘register_clear_session_function’

解决方法:
改为这样:

from tensorflow.python.keras.models import Sequential
from tensorflow.python.keras.layers.core import Dense,Dropout,Activation
from tensorflow.keras.optimizers import SGD,Adam
from tensorflow.python.keras.utils import np_utils
from tensorflow.python.keras.datasets import mnist

你可能感兴趣的:(Machine,Learning,tensorflow,python,深度学习)