Open ursb2017 opened 4 years ago
`import edward as ed import numpy as np import tensorflow as tf from edward.models.random_variables import * import sys
x_train = np.linspace(-3, 3, num=10) y_train = np.cos(x_train) + np.random.normal(0, 0.1, size=10) x_train = x_train.astype(np.float32).reshape((10, 1)) y_train = y_train.astype(np.float32).reshape((10, 1))
W_0 = Normal(loc=tf.zeros([1, 2]), scale=tf.ones([1, 2])) W_1 = Normal(loc=tf.zeros([2, 1]), scale=tf.ones([2, 1])) b_0 = Normal(loc=tf.zeros(2), scale=tf.ones(2)) b_1 = Normal(loc=tf.zeros(1), scale=tf.ones(1))
x = x_train y = Normal(loc=tf.matmul(tf.tanh(tf.matmul(x, W_0) + b_0), W_1) + b_1, scale=0.1)
qW_0 = Normal(loc=tf.get_variable("qW_0/loc", [1, 2]), scale=tf.nn.softplus(tf.get_variable("qW_0/scale", [1, 2]))) qW_1 = Normal(loc=tf.get_variable("qW_1/loc", [2, 1]), scale=tf.nn.softplus(tf.get_variable("qW_1/scale", [2, 1]))) qb_0 = Normal(loc=tf.get_variable("qb_0/loc", [2]), scale=tf.nn.softplus(tf.get_variable("qb_0/scale", [2]))) qb_1 = Normal(loc=tf.get_variable("qb_1/loc", [1]), scale=tf.nn.softplus(tf.get_variable("qb_1/scale", [1])))
inference = ed.KLqp({W_0: qW_0, b_0: qb_0, W_1: qW_1, b_1: qb_1}, data={y: y_train}) inference.run(n_iter=1)
`
Traceback (most recent call last):
File "D:/学习和科研/科研/研究项目/强化学习ing/RL/Bayesian_Inference/Test.py", line 33, in
I'm having the same problem when using the ed.copy()
I use the example code,but…