ModuleNotFoundError: No module named 'tensorflow.contrib' 解决方法

TensorFlow 2.0中contrib被弃用

于是将

from tensorflow.contrib import rnn

替换成

from tensorflow.python.ops import rnn

 

 

如果出现

AttributeError: module 'tensorflow.python.ops.rnn' has no attribute 'BasicLSTMCell'

则将
rnn.BasicLSTMCell(num_hidden,forget_bias=1.0)

替换

tf.nn.rnn_cell.BasicLSTMCell(num_hidden,forget_bias=1.0)

 

posted @ 2021-01-12 00:02  ziyuliu  阅读(9514)  评论(0编辑  收藏  举报