如何重塑 flutter (dart) 列表
How to reshape the flutter (dart) list
我正在使用 tflite 库,它需要一个形状为 [1, 150, 3] 的数组,我有 3 个 [150] 的数组,当我尝试制作 3 个列表的列表时,它的形状变为 [3 , 150] 并且在使用 .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]
我正在使用 tflite 库,它需要一个形状为 [1, 150, 3] 的数组,我有 3 个 [150] 的数组,当我尝试制作 3 个列表的列表时,它的形状变为 [3 , 150] 并且在使用 .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]