2
我無法調整矩陣 - 的set_shape
功能似乎 沒有任何效果:蟒蛇(SciPy的):調整稀疏矩陣
>>> M
<14x3562 sparse matrix of type '<type 'numpy.float32'>'
with 6136 stored elements in LInked List format>
>>> new_shape = (15,3562)
>>> M.set_shape(new_shape)
>>> M
<14x3562 sparse matrix of type '<type 'numpy.float32'>'
with 6136 stored elements in LInked List format>
任何人碰到這個?
我也試着用手這樣做,即
>>> M._shape = new_shape
>>> M.data = np.concatenate(M.data, np.empty((0,0), dtype=np.float32))
而是拋出了一個錯誤:
*** TypeError: only length-1 arrays can be converted to Python scalars
或
>>> M.data = np.concatenate(M.data, [])
*** TypeError: an integer is required
對於信息:
- 的Python 2.6.5(R265:79063,2010年4月16日,13:57:41)
- SciPy的0.11.0.dev-03f9e4a
古怪的是給我一個錯誤:'行= sparse.lil_matrix((1,3562))'然後'sparse.vstack(M,行)''給出*** NotImplementedError:添加標量到CSC或CSR矩陣不被支持「# – tdc 2012-03-08 17:24:29
和之前你問M絕對是一個律矩陣! – tdc 2012-03-08 17:29:48
@tdc:就是'sparse.vstack([M,row])'。 – 2012-03-08 17:40:40