什么是csr_matrix.A? [英] What is csr_matrix.A?

查看:345
本文介绍了什么是csr_matrix.A?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近看到了这样的东西:

I've recently seen something like this:

import numpy as np
row = np.array([0, 0, 1, 2, 2, 2])
col = np.array([0, 2, 2, 0, 1, 2])
data = np.array([1, 2, 3, 4, 5, 6])
from scipy.sparse import csr_matrix
csr_matrix((data, (row, col)), shape=(3, 3)).A

在这种情况下,它返回一个numpy数组:

In this case, it returns an numpy array:

array([[1, 0, 2],
       [0, 0, 3],
       [4, 5, 6]], dtype=int64)

这似乎只是稀疏矩阵的一种非稀疏表示形式,但是我不能在

This seems to be simply a non-sparse representation of the sparse matrix, but I cannot find it in the csr_matrix docs. Does anybody know for sure what the .A does?

推荐答案

.A is not from crs_matrix,它来自numpy:

the .A is not fromcrs_matrix, it is from numpy:

https://docs.scipy.org /doc/numpy/reference/generation/numpy.matrix.A.html

这篇关于什么是csr_matrix.A?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆