我用的是Conda。当我运行这段代码时,我得到了这个错误。我为此挣扎了两天,我试图更新Keras,conda和TensorFlow,但它没有工作。Keras和tensorflow版本2.11.0代码如下:
from tensorflow.keras.models import Sequential
from tensorflow.python.keras.models import Sequential
from tensorflow.python.keras.layers import Dense , Flatten,Embedding,Input,CuDNNLSTM,LSTM
from tensorflow.python.keras.models import Model
from tensorflow.python.keras.preprocessing.text import text_to_word_sequence
下面是我得到的错误:
属性错误:模块“tensorflow.python.saved_model.registration”没有属性“register_tf_serializable”
先谢谢你了
我尝试更新Keras、conda和TensorFlow,但没有成功。
1条答案
按热度按时间dced5bon1#
在导入上述库时,您需要删除
.python
。此外,tensorflow.python.keras.preprocessing.text api现在不建议使用,您可以使用提供等效功能的tf.strings.regex_replace
和tf.strings.split
。cuDNNLSTM
API在Tensorflow 1.x中使用,在Tensorflow 2.x中替换为LSTM
。您可以导入这些库,如下所示:
请验证您是否安装了正确的tensorflow版本,以及此测试构建配置中提到的兼容python版本。另外,请确保您没有在Windows操作系统中使用tensorflow 2.11来支持GPU,因为
原生Windows上的GPU支持仅适用于2.10或更早版本。从TF 2.11开始,Windows不支持CUDA构建。要在Windows上使用TensorFlow GPU,您需要在WSL2中构建/安装TensorFlow,或者将tensorflow-cpu与TensorFlow-DirectML-Plugin一起使用