Coreml:如何将数组 (1, 3, 80, 80, 19) 重塑为 (3, 6400, 19) 或 (1, 3, 6400, 19)

Posted

技术标签:

【中文标题】Coreml:如何将数组 (1, 3, 80, 80, 19) 重塑为 (3, 6400, 19) 或 (1, 3, 6400, 19)【英文标题】:Coreml: How to reshape an array (1, 3, 80, 80, 19) to (3, 6400, 19) or (1, 3, 6400, 19) 【发布时间】:2021-06-22 06:15:57 【问题描述】:

我有一个输入是 (1, 3, 80, 80, 19),我想将它重塑为 (3, 6400, 19) 或 (1, 3, 6400, 19)。我试过这样

 input_features = [
    ("714", datatypes.Array(1, 3, 80, 80, 19))]

builder.add_reshape(name='714_reshape', input_name='714', output_name='714_reshape', target_shape=(3, 6400, 19), mode=0)

但我收到此错误 Espresso 异常:“无效参数”:generic_reshape_kernel:用于重塑为 (19 6400 3 3 1) 的底部形状无效 (19 80 80 3 1)。

似乎 coreml 试图输出与我的输入相同的等级。有没有办法告诉 coreml 我想将轴 1 和 2 从 80x80 重塑为 6400?

【问题讨论】:

【参考方案1】:

试试add_reshape_static,它可以处理非 5 阶张量。旧的 reshape 层在这方面受到更多限制,有时会产生奇怪的行为。

【讨论】:

以上是关于Coreml:如何将数组 (1, 3, 80, 80, 19) 重塑为 (3, 6400, 19) 或 (1, 3, 6400, 19)的主要内容,如果未能解决你的问题,请参考以下文章