Keras that does not support TensorFlow 2.0. We recommend using `tf.keras`, or alternatively, downgrading to TensorFlow 1.14

南笙酒味 提交于 2020-01-05 08:27:09

问题


I am having an error regarding (Keras that does not support TensorFlow 2.0. We recommend using tf.keras, or alternatively, downgrading to TensorFlow 1.14.) any recommendations.

thanks

import keras
#For building the Neural Network layer by layer
from keras.models import Sequential
#To randomly initialize the weights to small numbers close to 0(But not 0)
from keras.layers import Dense

classifier=tf.keras.Sequential()

classifier.add(Dense(output_dim = 6, init = 'uniform', activation = 'relu', input_dim = 11))




RuntimeError: It looks like you are trying to use a version of multi-backend Keras that does not support TensorFlow 2.0. We recommend using `tf.keras`, or alternatively, downgrading to TensorFlow 1.14.

回答1:


You should only have to change the imports at the top:

from tensorflow.python.keras.layers import Dense
from tensorflow.python.keras import Sequential

classifier = Sequential()
classifier.add(Dense(6, init = 'uniform', activation = 'relu', input_dim = 11))



回答2:


TensorFlow 2.0+ is only compatible with Keras 2.3.0+, so if you wish to use Keras 2.2.5-, you'll need TensorFlow 1.15.0-. Alternatively, yes, you can do from tensorflow.keras import ..., but that will not use your keras package at all and you might as well uninstall it.



来源:https://stackoverflow.com/questions/59090404/keras-that-does-not-support-tensorflow-2-0-we-recommend-using-tf-keras-or-al

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!