tensorflow2.版本更新导致的1.x的问题

import tensorflow as tf
tf.reset_default_graph()

module ‘tensorflow’ has no attribute ‘reset_default_graph’
tf.reset_default_graph()修改为tf.compat.v1.reset_default_graph()

module ‘tensorflow’ has no attribute ‘placeholder’
tf.placeholder修改为tf.compat.v1.placeholder

tf.placeholder() is not compatible with eager execution.
添加语句tf.compat.v1.disable_eager_execution()

module ‘tensorflow’ has no attribute ‘Session’
tf.Session()改为tf.compat.v1.Session()

module ‘tensorflow’ has no attribute ‘contrib’
contrib.rnn.BasicLSTMCell改为tf.compat.v1.nn.rnn_cell.BasicLSTMCell
tf.contrib.rnn.DropoutWrapper改为tf.compat.v1.nn.rnn_cell.DropoutWrapper
tf.nn.dynamic_rnn改为tf.compat.v1.nn.dynamic_rnn

module ‘tensorflow’ has no attribute ‘truncated_normal’
tf.truncated_normal改为tf.random.truncated_normal

module ‘tensorflow._api.v2.train’ has no attribute ‘AdamOptimizer’
tf.train.AdamOptimizer改为tf.optimizers.Adam

module ‘tensorboard.summary._tf.summary’ has no attribute ‘merge_all’
tf.summary.merge_all()改为tf.compat.v1.summary.merge_all()

module ‘tensorboard.summary._tf.summary’ has no attribute ‘FileWriter’
tf.summary.FileWriter改为tf.compat.v1.summary.FileWriter

module ‘tensorflow’ has no attribute ‘InteractiveSession’
tf.InteractiveSession()改为tf.compat.v1.InteractiveSession()

module ‘tensorflow._api.v2.train’ has no attribute ‘Saver’
tf.train.Saver()改为tf.compat.v1.train.Saver()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值