linearcorex.py 文件源码

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

项目:LinearCorex 作者: gregversteeg 项目源码 文件源码
def pick_n_hidden(data, repeat=1, verbose=False, **kwargs):
    """A helper function to pick the number of hidden factors / clusters to use."""
    # TODO: Use an efficient search strategy
    max_score = - np.inf
    n = 1
    all_scores = []
    while True:
        scores = []
        for _ in range(repeat):
            out = Corex(n_hidden=n, gpu=False, **kwargs).fit(data)
            m = out.moments
            scores.append(m["TC_no_overlap"])
        score = max(scores)
        if verbose:
            print(("n: {}, score: {}".format(n, score)))
        all_scores.append((score, n))
        if score < 0.95 * max_score:
            break
        else:
            n += 1
            if score > max_score:
                max_score = score
    return all_scores
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号