大型门户网站建设哪专业,南沙区网站建设,黑白摄影网站,网站建设公司推荐在TensorFlow2环境下执行1.X版本的代码时报错#xff1a; AttributeError: module ‘tensorflow‘ has no attribute ‘contrib‘ 当然第一时间想到的是利用 如下代码 来解决问题#xff08;大部分情况都是这样#xff09;#xff0c;
tf.compat.v1但是又出现以下报错 Att…在TensorFlow2环境下执行1.X版本的代码时报错 AttributeError: module ‘tensorflow‘ has no attribute ‘contrib‘ 当然第一时间想到的是利用 如下代码 来解决问题大部分情况都是这样
tf.compat.v1但是又出现以下报错 AttributeError: module ‘tensorflow.compat.v1’ has no attribute ‘contrib‘ 表示这个库中也没有该函数。 查阅资料以及实验发现是选择库的问题需要修改如下
# 原始代码
lstm_enc tf.contrib.rnn.LSTMCell(num_units)# 修改后代码
lstm_enc tf.compat.v1.nn.rnn_cell.LSTMCell(num_units)最后运行不报错。