模块未找到错误:tensorflow = 2.0.0中没有名为“tensorflow.contrib”的模块。

7

我正在使用TensorFlow版本2.0.0和Python版本3.7.3。我尝试导入以下语句:

from tensorflow.contrib import rnn

它报错了,显示"Module 'tensorflow' has no attribute 'contrib'"。我该怎么解决?


如果你把一个文件命名为tensorflow.py,请选择一个不同的名字。 - user2357112
2个回答

1

1
请问如何在tensorflow 2.0中使用这些附加库? - kriti
抱歉,模块已被弃用,意味着它在此版本中已经不存在。 - Naor Tedgi
2
有没有其他的替代方案?我有一个使用这个模块的代码库,我需要升级它。 - Betelgeuse

1

1
使用此代码会出现错误,错误信息为AttributeError: module 'tensorflow_core._api.v2.nn' has no attribute 'rnn_cell'。实际上,我正在尝试像这样做:self.cell = tf.nn.rnn_cell.BasicLSTMCell - kriti
你无法导入Keras层吗? - bug_spray
https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/keras/layers/LSTMCell - bug_spray
import tensorflow.keras.layers as layers then... self.cell = layers.LSTMCell(units=units, activation=activation, dropout=dropout) - bug_spray

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接