data_augmentation.py 文件源码

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

项目:pl-cnn 作者: oval-group 项目源码 文件源码
def test_horizontal_flip_with_swap(self):
        """
        Test horizontal flip with swapping axes
        NB: horizontal flip <=> reverse order on columns
        """

        np.random.seed(0)

        # 5 images of size 10 x 10 x 3
        shape = [5, 10, 10, 3]
        batch = np.random.random(size=shape).astype(np.float32)

        # move axis and then flip horizontally
        flipped_1 = np.moveaxis(batch, 3, 1)[:, :, :, ::-1]

        # flip horizontally without moving axis
        flipped_2 = batch[:, :, ::-1, :]

        for i in range(shape[0]):
            for j in range(shape[3]):
                assert np.all(np.isclose(flipped_1[i, j],
                                         flipped_2[i, :, :, j]))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号