np_utils.py 文件源码

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

项目:hamaa 作者: monitor1379 项目源码 文件源码
def rot180(images):
    """
    ????180??
    ??HW/CHW/NCHW?????images?
    """
    out = np.empty(shape=images.shape, dtype=images.dtype)
    if images.ndim == 2:
        out = np.rot90(images, k=2)
    elif images.ndim == 3:
        for c in xrange(images.shape[0]):
            out[c] = np.rot90(images[c], k=2)
    elif images.ndim == 4:
        for n in xrange(images.shape[0]):
            for c in xrange(images.shape[1]):
                out[n][c] = np.rot90(images[n][c], k=2)
    else:
        raise Exception('Invalid ndim: ' + str(images.ndim) +
                        ', only support ndim between 2 and 4.')
    return out


# ????f????x???f???df???x???
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号