test_online_GMM.py 文件源码

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

项目:megamix 作者: 14thibea 项目源码 文件源码
def test_step_M(self,window,update):
        points = np.random.randn(self.n_points,self.dim)
        GM = GaussianMixture(self.n_components,window=window,update=update)
        GM.initialize(points)

        _,log_resp = GM._step_E(points[:GM.get('window'):])
        GM._sufficient_statistics(points[:GM.get('window'):],log_resp)

        log_weights = np.log(GM.get('N'))
        means = GM.get('X') / GM.get('N')[:,np.newaxis]
        cov = GM.get('S') / GM.get('N')[:,np.newaxis,np.newaxis]
        cov_chol = np.empty_like(cov)
        for i in range(self.n_components):
            cov_chol[i] = linalg.cholesky(cov[i],lower=True)

        GM._step_M()

        assert_almost_equal(log_weights,GM.get('log_weights'))
        assert_almost_equal(means,GM.get('means'))
        assert_almost_equal(cov,GM.get('cov'))
        assert_almost_equal(cov_chol,GM.get('cov_chol'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号