cryptic scipy “could not convert integer scalar” error

前端 未结 3 616
南方客
南方客 2020-12-19 12:35

I am constructing a sparse vector using a scipy.sparse.csr_matrix like so:

csr_matrix((values, (np.zeros(len(indices)), indices)), shape = (1, m         


        
3条回答
  •  猫巷女王i
    2020-12-19 13:12

    The max index you are giving is less than the maximum index of the rows you are supplying.

    This sparse.csr_matrix((vals, (np.zeros(10), inds)), shape = (1, np.max(inds)+1)) works fine with me.

    Although making a .todense() results in memory error for the large size of the matrix

提交回复
热议问题