model.py 文件源码

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

项目:ShuffleNet 作者: jaxony 项目源码 文件源码
def channel_shuffle(x, groups):
    batchsize, num_channels, height, width = x.data.size()

    channels_per_group = num_channels // groups

    # reshape
    x = x.view(batchsize, groups, 
        channels_per_group, height, width)

    # transpose
    # - contiguous() required if transpose() is used before view().
    #   See https://github.com/pytorch/pytorch/issues/764
    x = torch.transpose(x, 1, 2).contiguous()

    # flatten
    x = x.view(batchsize, -1, height, width)

    return x
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号