base_models.py 文件源码

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

项目:geepee 作者: thangbui 项目源码 文件源码
def predict_forward_mc(self, T, x_control, no_samples):
        """Summary

        Args:
            T (TYPE): Description
            x_control (None, optional): Description

        Returns:
            TYPE: Description
        """
        x = np.zeros((T, no_samples, self.Din))
        my = np.zeros((T, no_samples, self.Dout))
        vy = np.zeros((T, no_samples, self.Dout))
        post_m, post_v = self.get_posterior_x()
        mtm1 = post_m[[-1], :]
        vtm1 = post_v[[-1], :]
        eps = np.random.randn(no_samples, self.Din)
        x_samples = eps * np.sqrt(vtm1) + mtm1
        for t in range(T):
            if self.Dcon_dyn > 0:
                xc_samples = np.hstack((x_samples, np.tile(x_control[[t], :], [no_samples, 1])))
            else:
                xc_samples = x_samples
            mt, vt = self.dyn_layer.forward_prop_thru_post(xc_samples)
            eps = np.random.randn(no_samples, self.Din)
            x_samples = eps * np.sqrt(vt) + mt
            if self.Dcon_emi > 0:
                xc_samples = np.hstack((x_samples, np.tile(x_control[[t], :]), [no_samples, 1]))
            else:
                xc_samples = x_samples
            if self.gp_emi:
                mft, vft = self.emi_layer.forward_prop_thru_post(xc_samples)
                myt, vyt_n = self.lik_layer.output_probabilistic(mft, vft)
            else:
                myt, _, vyt_n = self.emi_layer.output_probabilistic(xc_samples, np.zeros_like(x_samples))
                vyt_n = np.diagonal(vyt_n, axis1=1, axis2=2)
            x[t, :, :] = x_samples
            my[t, :, :], vy[t, :, :] = myt, vyt_n
        return x, my, vy
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号