InferPy
InferPy copied to clipboard
check consistency in the names of the q variables
It could happen that the user wrongly specified the variables names in the Q model. At least, a warning should be shown. For instance, consider the following example where the qw0 should be named w0
@inf.probmodel
def linear_reg(d):
w0 = inf.Normal(0, 1, name="w0")
w = inf.Normal(0, 1, batch_shape=[d,1], name="w")
with inf.datamodel():
x = inf.Normal(5, 2, batch_shape=d, name="x")
y = inf.Normal(w0 + x @ w, 1.0, name="y")
@inf.probmodel
def qmodel(d):
qw0_loc = inf.Parameter(0., name="qw0_loc")
qw0_scale = tf.math.softplus(inf.Parameter(1., name="qw0_scale"))
qw0 = inf.Normal(qw0_loc, qw0_scale, name="qw0")
qw_loc = inf.Parameter(tf.zeros([d,1]), name="qw_loc")
qw_scale = tf.math.softplus(inf.Parameter(tf.ones([d,1]), name="qw_scale"))
qw = inf.Normal(qw_loc, qw_scale, name="w")