【问题标题】:Array dimension reshape数组维度重塑
【发布时间】:2021-05-20 20:04:26
【问题描述】:

我有一个维度 (300, 2, 17, 80) 的数组,它是 2 个维度 (17,80) 图像的 300 个样本。 我想重塑阵列以提供我的 CNN,例如 (300, 17, 80, 2)。 我怎样才能做到这一点 ? 感谢您的支持。

【问题讨论】:

标签: python arrays multidimensional-array


【解决方案1】:

您可以为此目的使用np.moveaxis。例如,

import numpy as np
M = np.zeros((300,2,17,80))
print(M.shape)
M = np.moveaxis(M, 1, -1)
print(M.shape)

np.moveaxis(M, 1, -1) 调用通过使用轴索引=-1 将轴索引=1 的第二个轴移动到最后一个位置。

【讨论】:

    猜你喜欢
    • 2017-06-10
    • 2020-03-18
    • 2012-09-28
    • 2014-04-21
    • 1970-01-01
    • 2013-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多