我試圖重新,但我不能:
>>> import numpy as np
>>> arrs = np.random.randn(10000, 7000)
>>> arrs
array([[ 1.07575627, 0.16139542, 1.92732122, ..., -0.26905029,
0.73061849, -0.61021016],
[-0.61298112, 0.58251565, -1.0204561 , ..., 1.73095028,
0.25763494, 0.03769834],
[ 1.08827523, 1.67841947, -0.08118218, ..., -0.4315941 ,
1.41509082, 0.59479981],
...,
[ 0.7457839 , 0.20886401, 1.07463208, ..., 0.79508743,
0.15184803, -0.34028477],
[-0.25272939, 0.17744917, -1.45035157, ..., -0.54263528,
0.04489259, -0.41222399],
[ 1.58635482, 2.2273889 , 1.1803809 , ..., 0.8501827 ,
-0.43804703, 0.78975036]])
>>> lists = [list(arr) for arr in arrs]
>>> len(lists)
10000
>>> all(len(lis) == 7000 for lis in lists)
True
>>> mat = np.matrix(lists)
和mat
現在是:
>>> mat
matrix([[ 1.07575627, 0.16139542, 1.92732122, ..., -0.26905029,
0.73061849, -0.61021016],
[-0.61298112, 0.58251565, -1.0204561 , ..., 1.73095028,
0.25763494, 0.03769834],
[ 1.08827523, 1.67841947, -0.08118218, ..., -0.4315941 ,
1.41509082, 0.59479981],
...,
[ 0.7457839 , 0.20886401, 1.07463208, ..., 0.79508743,
0.15184803, -0.34028477],
[-0.25272939, 0.17744917, -1.45035157, ..., -0.54263528,
0.04489259, -0.41222399],
[ 1.58635482, 2.2273889 , 1.1803809 , ..., 0.8501827 ,
-0.43804703, 0.78975036]])
>>> mat.shape
(10000, 7000)
你能有一個小例子重現呢? – Akavall 2014-12-01 23:00:52
並且是你長度相同的子列表嗎? – Akavall 2014-12-01 23:02:18