scipy csc csr到底是什麼東西,scipycsccsr東西

來源:互聯網
上載者:User

scipy csc csr到底是什麼東西,scipycsccsr東西

哎,真尼瑪,網上關於scipy 和 theano的 sparse matrix中的 csc matrix 和 csr matrix太少了,有,也只是使用,並沒有說明,那個矩陣是怎麼產生的。參考例子:
>>> data = np.asarray([7, 8, 9])>>> indices = np.asarray([0, 1, 2])>>> indptr = np.asarray([0, 2, 3, 3])>>> m = sp.csc_matrix((data, indices, indptr), shape=(3, 3))>>> print m.toarray()[[7 0 0] [8 0 0] [0 9 0]]

這裡面indices 還好說,就是非零資料7,8,9這三個數在矩陣裡的行數,那inptr是什麼鬼玩意,其全拼是 index pointer array。根本不知道幹什麼用的,最終原來是這樣的,我們還以上面的例子為例:

data:      7     8      9

indices:0      1      2

indptr:   0              2      3    3

就是說7和8是0列的,9是1列的。7在0列0行上,8在0列1行上,9在1列2行上,其餘元素全部為0,這樣就形成了

[7 0 0] [8 0 0] [0 9 0]]
其實這是源於csparse的,關於這有一個更好的例子: csparse

大家如果對這個還不清楚,我這個曾經深受其害的人願意提供更多解答。





聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.