TensorFlow 2.0与1.0相关API各种坑

问题1.AttributeError: module ‘tensorflow’ has no attribute ‘placeholder’
解决方法:
将i
mport tensorflow as tf
替换为
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

问题2.NameError: name ‘xavier’ is not defined
解决方法:
w_init= tf.random_normal_initializer()
b_init=tf.zeros_initializer()

G_W1=tf.Variable( w_init([100,128]),name=“G_W1”)
G_b1 = tf.Variable(b_init(shape=[128]),name=‘G_b1’)
G_W2 = tf.Variable( w_init([128,784]),name=‘G_W2’)
G_b2 = tf.Variable(b_init(shape=[784]),name=‘G_b2’)
theta_G=[G_W1,G_b1,G_W2,G_b2]
问题3:Tensorflow 2.0 !!! No module named 'tensorflow.examples.tutorials’解决办法
解决办法

问题4:获取MNIST数据的几种方法

发布了2 篇原创文章 · 获赞 0 · 访问量 82

猜你喜欢

转载自blog.csdn.net/weixin_39945925/article/details/104089165