我有一个包含 numpy 矩阵的列表。无论如何,我可以将整个事情变成一个漂亮的干净的 numpy 数组吗?
From:
[matrix([[1]]), matrix([[ 1.99387871]]), matrix([[ 2.53564618]]), matrix([[ 4.39125807]]), matrix([[ 4.246309]]), matrix([[ 5.21571607]]), matrix([[ 6.17408811]]), matrix([[ 4.75146571]]), matrix([[ 6.19319742]]), matrix([[ 6.1277607]]), matrix([[ 7.43821216]])]
To:
[[1 1.99387871 2.53564618 4.39125807 4.246309 5.21571607 6.17408811 4.75146571 6.19319742 6.1277607 7.43821216]]
b = np.asarray(a, dtype=float)
#to get the same shape do.
b = b.reshape(-1, len(b))
#to just get one dimmension do.
b = np.asarray(a, dtype=float).reshape(len(a))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)