Set some parameter and corresponding q parameters to a fixed value, like 0


I have a multi-dimensional parameter,

beta = Normal(loc=tf.zeros([FLAGS.S, FLAGS.S, FLAGS.D], dtype=tf.float32), scale=1.0 * tf.ones(FLAGS.D, dtype=tf.float32))

and its variance approximation

qbeta_loc = tf.get_variable("qbeta_loc", [FLAGS.S, FLAGS.S, FLAGS.D], dtype=tf.float32)
qbeta_scale = tf.nn.softplus(tf.get_variable("qbeta_scale", [FLAGS.S, FLAGS.S, FLAGS.D], dtype=tf.float32))
qbeta = Normal(loc=qbeta_loc, scale=qbeta_scale)

But I know some of its element are going to be always 0. Is there a way to specify this?


Multiply the parameter tensor element-wise by a binary mask wherever it appears.

mask = [0, 0, ..., 1, 1, ...]
py = g(mask * beta, ...)


I do that in model execution code. However, as declared, the Random Variables are still sampled from Normal, so I don’t suppose there is any way to declare some elements to be zero.