我就废话不多说了,如下所示:
>>>from compiler.ast import flatten >>>X matrix([[ 1, 17, 13, 221, 289, 169], [ 1, 17, 14, 238, 289, 196], [ 1, 17, 15, 255, 289, 225], [ 1, 18, 13, 234, 324, 169], [ 1, 18, 14, 252, 324, 196], [ 1, 18, 15, 270, 324, 225], [ 1, 19, 13, 247, 361, 169], [ 1, 19, 14, 266, 361, 196], [ 1, 19, 15, 285, 361, 225]]) >>>x = X.tolist() >>>x [[ 1, 17, 13, 221, 289, 169], [ 1, 17, 14, 238, 289, 196], [ 1, 17, 15, 255, 289, 225], [ 1, 18, 13, 234, 324, 169], [ 1, 18, 14, 252, 324, 196], [ 1, 18, 15, 270, 324, 225], [ 1, 19, 13, 247, 361, 169], [ 1, 19, 14, 266, 361, 196], [ 1, 19, 15, 285, 361, 225]] >>>xx = flatten(x) (或者x.ravel() ) >>>xx [1, 17, 13, 221, 289, 169, 1, 17, 14, 238, 289, 196, 1, 17, 15, 255, 289, 225, 1, 18, 13, 234, 324, 169, 1, 18, 14, 252, 324, 196, 1, 18, 15, 270, 324, 225, 1, 19, 13, 247, 361, 169, 1, 19, 14, 266, 361, 196, 1, 19, 15, 285, 361, 225]
以上这篇python 实现多维数组转向量就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持亿速云。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。