hmc_samplers.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:bnn-analysis 作者: myshkov 项目源码 文件源码
def _leapfrog_step(self, position, velocity, velocity_step_multiplier=1.):
        """ Makes a single leapfrog step with friction. """
        d_energy = self._d_energy_fn(position)

        friction = self.friction
        deceleration = -friction * self._transpose_mul(velocity, self._current_step_size)

        velocity -= self._transpose_mul(d_energy, velocity_step_multiplier * self._current_step_size)
        velocity += deceleration

        # B_hat = 0, C = friction
        noise = tf.random_normal(tf.shape(velocity))
        stddevs = (2 * friction * self._current_step_size) ** 0.5
        noise = self._transpose_mul(noise, stddevs)

        velocity += noise

        position = position + self._transpose_mul(velocity, self._current_step_size)

        return position, velocity
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号