[英]How to reshape the flutter (dart) list
Iam working with tflite library which requires an array with shape of [1, 150, 3] and i have 3 arrays of [150], when i try to make a list of the 3 list it shapes become [3, 150] and when using.reshape() it ruins the whole order i just need to reverse the dimensions of the list.我正在使用 tflite 库,它需要一个形状为 [1, 150, 3] 的数组,我有 3 个 arrays [150],当我尝试列出 3 个列表时,它的形状变为 [3, 150] 并且当using.reshape() 它破坏了我只需要反转列表维度的整个顺序。
code snippets:代码片段:
[rs, gs, bs].reshape([150, 3]
simple explanation What happens:简单解释 发生了什么:
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]
What i need:我需要的:
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]
Use the transpose method from: https://pub.dev/packages/matrix2d使用转置方法来自: 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.