test_transformer.py 文件源码

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

项目:nuts-ml 作者: maet3608 项目源码 文件源码
def test_RegularImagePatches():
    img1 = np.reshape(np.arange(12), (3, 4))

    samples = [(img1, 0)]
    get_patches = RegularImagePatches(0, (2, 2), 2)
    expected = [(np.array([[0, 1], [4, 5]]), 0),
                (np.array([[2, 3], [6, 7]]), 0)]
    patches = samples >> get_patches >> Collect()
    for (p, ps), (e, es) in zip(patches, expected):
        nt.assert_allclose(p, e)
        assert ps == es

    samples = [(img1, img1 + 1)]
    get_patches = RegularImagePatches((0, 1), (1, 1), 3)
    expected = [(np.array([[0]]), np.array([[1]])),
                (np.array([[3]]), np.array([[4]]))]
    patches = samples >> get_patches >> Collect()
    for p, e in zip(patches, expected):
        nt.assert_allclose(p, e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号