繁体   English   中英

如何重塑 flutter (dart) 列表

[英]How to reshape the flutter (dart) list

我正在使用 tflite 库,它需要一个形状为 [1, 150, 3] 的数组,我有 3 个 arrays [150],当我尝试列出 3 个列表时,它的形状变为 [3, 150] 并且当using.reshape() 它破坏了我只需要反转列表维度的整个顺序。

代码片段:

[rs, gs, bs].reshape([150, 3]

简单解释 发生了什么:

before reshape: [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]

after reshape: [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]

我需要的:

before reshape: [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]

after reshape: [1, 6, 11], [2, 7, 12], [3, 8, 13], [4, 9, 14], [5, 10, 15]

使用转置方法来自: https://pub.dev/packages/matrix2d

List before = [
    [1, 2, 3, 4, 5],
    [6, 7, 8, 9, 10],
    [11, 12, 13, 14, 15]
  ];

  print(before.transpose); //[1, 6, 11], [2, 7, 12], [3, 8, 13], [4, 9, 14], [5, 10, 15]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM