def __call__(self, inputs, steps):
def fn(zv, x):
"""
Transition for training, without Metropolis-Hastings.
`z` is the input state.
`v` is created as a dummy variable to allow output of v_, for training p(v).
:param x: variable only for specifying the number of steps
:return: next state `z_`, and the corresponding auxiliary variable `v_`.
"""
z, v = zv
v = tf.random_normal(shape=tf.stack([tf.shape(z)[0], self.network.v_dim]))
z_, v_ = self.network.forward([z, v])
return z_, v_
elems = tf.zeros([steps])
return tf.scan(fn, elems, inputs, back_prop=True)
评论列表
文章目录