本文介绍了在python中随机随机播放稀疏矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种简单的方法可以在python中随机播放稀疏矩阵?
is there an easy way to shuffle a sparse matrix in python?
这是我改组非稀疏矩阵的方式:
This is how I shuffle a non-sparse matrix:
index = np.arange(np.shape(matrix)[0])
np.random.shuffle(index)
return matrix[index]
我该如何用numpy稀疏处理呢?
How can I do it with numpy sparse?
推荐答案
好,找到了.稀疏格式在打印输出中看起来有些混乱.
Ok, found it. The sparse format looks a bit confusing in the print-out.
index = np.arange(np.shape(matrix)[0])
print index
np.random.shuffle(index)
return matrix[index, :]
这篇关于在python中随机随机播放稀疏矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!