test_vectors.py 文件源码

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

项目:conceptnet5 作者: ymmah 项目源码 文件源码
def test_shrink_and_sort(frame=None):
    if not frame:
        frame = DATA + '/vectors/glove12-840B.h5'
    vectors = load_any_embeddings(frame)

    n, k = 10, 20
    shrank = shrink_and_sort(vectors, n, k)

    # Check the size of the frame
    ok_(shrank.shape == (n, k))

    # Check if the frame is l2 normalized
    lengths = np.sqrt(np.sum(np.power(shrank, 2), axis='columns'))
    ok_(all(isclose(length, 1.0, rel_tol=1e-04) for length in lengths))

    # Check if the index is sorted
    ok_(shrank.index.is_monotonic_increasing)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号