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