I am new to Edward, but I find that most of the available turtorials are on variational inference. Is there any tutorials on inference by MCMC? Especially, I hope a case with simple Bayesian linear regression.
Below is my code. It seems there is a dimension mismatch problem. I am rather confused on this issue.
from edward.models import Normal,Empirical
import numpy as np
import edward as ed
import tensorflow as tf
def build_toy_dataset(N, w, noise_std=0.1):
D = len(w)
x = np.random.randn(N, D)
y = np.dot(x, w) + np.random.normal(0, noise_std, size=N)
return x, y
import time
time_start=time.clock()
N = 40 # number of data points
D = 10 # number of features
n_chain=1000;
w_true = np.random.randn(D)
X_train, y_train = build_toy_dataset(N, w_true)
X_test, y_test = build_toy_dataset(N, w_true)
X = tf.placeholder(tf.float32, [N, D])
w = Normal(loc=tf.zeros(D), scale=tf.ones(D))
b = Normal(loc=tf.zeros(1), scale=tf.ones(1))
y = Normal(loc=ed.dot(X, w) + b, scale=tf.ones(N))
qw=Empirical(params=tf.Variable(tf.zeros([n_chain,D])))
qb=Empirical(params=tf.Variable(tf.zeros((n_chain,1))))
inference = ed.Gibbs({w:qw,b: qb}, data={X:X_train,y: y_train})
inference.run()