ndarry 转 csr_matrix
>>> import numpy as np
>>> import scipy.sparse

>>> my_matrix = scipy.sparse.csr_matrix((2,2))
>>> my_array = my_matrix.A
>>> type(my_array)
numpy.ndarray
1
2
3
4
5
6
7
csr_matrix 转 ndarray
>>> import numpy as np
>>> from scipy import sparse
>>> A = np.array([[1,2,0],[0,0,3],[1,0,4]])

>>> A
array([[1, 2, 0],
[0, 0, 3],
[1, 0, 4]])

>>> sA = sparse.csr_matrix(A) # Here's the initialization of the sparse matrix.

>>> sA
<3x3 sparse matrix of type '<type 'numpy.int32'>'
with 5 stored elements in Compressed Sparse Row format>

>>> print sA
(0, 0) 1
(0, 1) 2
(1, 2) 3
(2, 0) 1
(2, 2) 4

最新文章

  1. ajax分页与组合查询配合使用
  2. HLS视频点播&amp;直播初探
  3. java之数组
  4. Test Controller Tool
  5. 锋利的Jquery解惑系列(二)------插件开发大总结
  6. bzoj1799
  7. Linux鸟哥的私房菜(3)— 总体规划和磁盘分区 读书笔记
  8. 修改tomcat的get方法的参数长度
  9. C# 异步编程2 EAP 异步程序开发
  10. js求和运算在可变参数的情况下ES3、ES5和ES6的写法区别
  11. 网站robots.txt &amp; sitemap.xml
  12. Shader 屏幕后期特效 Shake(震屏)&amp;Wave(波纹)
  13. org.hibernate.MappingException: class com.itheima.domain.Customer.java not found while looking for property: cust_id at org.hibernate.internal.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.
  14. Groovy 类名称赋值为变量使用(newInstance &amp; new)
  15. #WEB安全基础 : HTTP协议 | 0x6 初识HTTP报文
  16. ODAC(V9.5.15) 学习笔记(三)TOraSession(4)
  17. day11-mysql中的mysql数据库不见了
  18. Python——eventlet.backdoor
  19. 自己写的jQuery颜色插件
  20. js中哈希表的几种用法总结

热门文章

  1. Vue ref属性
  2. 2023.3.4Leecode982按位与为零的三元组
  3. CF1764G1 题解
  4. SSM整合【狂神说】
  5. dns服务之bind配置内网解析部分子域名,其它子域名转发
  6. cookie,session,token,drf-jwt
  7. 【Java】取n工作日后的日期(仅排除周六周日)
  8. Springboot多数据源使用示例
  9. Java-根据父级id将List结构转Tree结构
  10. DEDE在文章列表文章没有缩略图的不显示图片,有的则显示缩略图