其他分享
首页 > 其他分享> > AttributeError: module ‘tensorflow._api.v2.train‘ has no attribute ‘NewCheckpointReader‘解决方案

AttributeError: module ‘tensorflow._api.v2.train‘ has no attribute ‘NewCheckpointReader‘解决方案

作者:互联网

解决AttributeError: module ‘tensorflow._api.v2.train’ has no attribute ‘NewCheckpointReader’


问题描述:

TensorFlow版本是2.8.0,执行如下代码:

reader = tf.train.NewCheckpointReader(filename)

报错如下:

AttributeError: module 'tensorflow._api.v2.train' has no attribute 'NewCheckpointReader'

原因分析:

TensorFlow 2.0.0以上的版本没有 tf.train.NewCheckpointReader 了。


解决方案:

tf.compat.v1.train.NewCheckpointReader 替换 tf.train.NewCheckpointReader 即可。

# reader = tf.train.NewCheckpointReader(filename)
reader = tf.compat.v1.train.NewCheckpointReader(filename)

tf.compat.v1.train.NewCheckpointReader

标签:compat,no,attribute,module,NewCheckpointReader,train,tf
来源: https://blog.csdn.net/qq_39691492/article/details/123093603