test_similarity.py 文件源码

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

项目:sef 作者: passalis 项目源码 文件源码
def test_similarity_calculations():
    """
    Tests the implementation of fast similarity calculations with the PyTorch
    :return:
    """
    np.random.seed(1)

    # Create random data vectors
    for sigma in [0.01, 0.1, 0.5, 1]:
        A = np.random.randn(10, 23)
        sef_sim = fast_heat_similarity_matrix(A, sigma)

        assert sef_sim.shape[0] == 10
        assert sef_sim.shape[1] == 10

        sim = np.exp(-pairwise_distances(A, A)**2/sigma**2)
        assert np.sum((sef_sim-sim)*2) < 1e-3
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号