我需要一个大小为(62500 x 62500)的负单位矩阵。 使用numpy声明正常的身份矩阵就像一个符咒:
eye = np.eye(62500, 62500)
但是,这样做,
negative_eye1 = np.negative(np.eye(62500, 62500))
# or
negative_eye2 = np.eye(62500, 62500) * -1
将导致此错误
Unable to allocate array with shape (62500, 62500) and data type float64
然后在scipy.sparse.bmat()
函数中使用该矩阵,从而生成csr矩阵,在该矩阵中,内存不再是这样的问题
我如何计算这个矩阵
可以使用scipy.sparse.eye(对角线上的稀疏矩阵):
相关问题 更多 >
编程相关推荐