使用爱德华兹库在MNIST数据集上的贝叶斯神经网络。 “ RecursionError:调用Python对象时超出了最大递归深度”

时间:2019-10-21 18:19:17

标签: python tensorflow edward

我正在尝试在Google colab上为MNIST数据集运行贝叶斯神经网络的代码。但是我遇到了递归错误。请帮忙。

x = tf.placeholder(tf.float32, [None, D])

w = Normal(loc = tf.zeros([D, k]), scale = tf.ones([D, k]))
b = Normal(loc = tf.zeros(k), scale = tf.ones(k))
y = Categorical(tf.matmul(x,w)+b)
qw = Normal(loc=tf.Variable(tf.random_normal([D, k])), scale=tf.nn.softplus(tf.Variable(tf.random_normal([D, k]))))
qb = Normal(loc=tf.Variable(tf.random_normal([k])), scale=tf.nn.softplus(tf.Variable(tf.random_normal([k]))))
y_ph = tf.placeholder(tf.int32, [N])
inference = ed.KLpq({w: qw, b: qb}, data={y:y_ph})
inference.initialize(n_iter=5000, n_print=100, scale={y: float(mnist.train.num_examples) / N})
sess = tf.InteractiveSession()
tf.global_variables_initializer().run()

错误在“ inference.initialize ...”行中。

RecursionError:调用Python对象时超出了最大递归深度

0 个答案:

没有答案