小白复现代码时遇到的问题。
常见问题一般的不兼容问题,都可以用以下方法得到解决。
①(兼容v1版本)tf.改为tf.compat.v1
②(兼容v1版本,且禁用v2版本)tf.改为tf.compat.v1,且加上tf.compat.v1.disable_v2_behavior()
例如:
tf.compat.v1.AUTO_REUSE
tf.compat.v1.disable_v2_behavior() #禁用v2版本 或 tf.compat.v1.disable_eager_execution() #tf2.0默认开启eager_execution(),关闭即可 tf.compat.v1.placeholder()
tf.compat.v1.variable_scope()
from tensorflow.python.ops import rnn, rnn_cell
tf.compat.v1.nn.rnn_cell.MultiRNNCell()
tf.compat.v1.nn.dynamic_rnn()
tf.compat.v1.nn.rnn_cell.BasicLSTMCell()
tf.compat.v1.nn.rnn_cell.LayerNormBasicLSTMCell()
tf.compat.v1.reset_default_graph()
tf.compat.v1.trainable_variables()
tf.compat.v1.losses.sigmoid_cross_entropy()
tf.compat.v1.losses.mean_squared_error()
tf.compat.v1.train.AdamOptimizer().minimize()
tf.compat.v1.Session()
tf.compat.v1.global_variables_initializer()其他问题
①tf2.0里面没有全连接函数tf.contrib.layers.fully_connected()
本文参考博文博文地址
在环境中下载了tf_slim,并在代码中进行导入import tf_slim。
tf_slim.fully_connected()



