【问题标题】:Change Image format from NHWC to NCHW for Pytorch将 Pytorch 的图像格式从 NHWC 更改为 NCHW
【发布时间】:2019-01-23 16:12:41
【问题描述】:

在 pytorch 中,我们需要 NCHW 格式的图像,但我的图像是 NHWC

将此图像输入 CNN 的过程是什么? (我发现this solution 建议使用“permute”,但我应该在哪里以及如何使用它?)

【问题讨论】:

    标签: image deep-learning permutation conv-neural-network pytorch


    【解决方案1】:

    使用torch.Tensor.permute()

     x = x.permute(0, 3, 1, 2) # from NHWC to NCHW
    

    【讨论】:

    • 这等于 np.transpose() 吗?
    • 它基本上做同样的事情,是的(具有 PyTorch 的优势,例如 GPU 支持)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-19
    • 2016-10-07
    • 1970-01-01
    • 2021-06-08
    • 1970-01-01
    相关资源
    最近更新 更多