有没有一种快速的方法可以从 numpy 数组中提取值?

Is there a quick way to extract values from a numpy array?

假设有一个包含 numpy 数组的列表,例如

import numpy as np 
output = [np.array([[[5.21]],
                    [[2.22]],
                    [[1.10]],
                    [[3.76]]], dtype=np.float32)]

有什么快速的方法可以从此输出列表中提取值,例如

result = [5.21, 2.22, 1.10, 3.76]

非常感谢

是的。试试这个

result = output[0].reshape(1,-1).flatten().tolist()