test_inference_plda.py 文件源码

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

项目:plda 作者: RaviSoji 项目源码 文件源码
def test_?_b(self):
#    """ ?_b = [A][?][A^T]. See p. 533.
#
#    DESCRIPTION: Since A and ? are free parameters, they will not necessarily
#                  recover the original A & ?. ?_b is what really describes
#                  the covariance between cluster means (see p. 533), so that
#                  is what you want to test - they are 'closer' to the data".
#    """
        n_classes_list = [4 ** x for x in range(1, 6)]
        n_list = [100 * n for n in n_classes_list]
        n_list = np.array(n_list).astype(float)
        n_dims = self.n_dims

        ?_b_L1_errors = []
        for n, n_classes in zip(n_list, n_classes_list):
            A, ?, model = self.experiment(int(n), n_dims, n_classes)

            ?_b = np.matmul(np.matmul(A, ?), A.T)
            ?_b_model = np.matmul(np.matmul(model.A, model.?), model.A.T)

            L1_error = np.abs(?_b - ?_b_model).mean()
            abs_? = (np.abs(?_b).mean() + np.abs(?_b_model).mean()) * .5
            percent_error = L1_error / abs_? * 100
            ?_b_L1_errors.append(percent_error)
            print('Testing ?_b with {} classes: {} percent error'.format(
                  n_classes, percent_error))

        Y = ?_b_L1_errors
        X = [x for x in range(len(?_b_L1_errors))]
        slope_of_error_vs_N = linregress(X, Y)[0]
        self.assertTrue(slope_of_error_vs_N < 0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号