Python中的shape计算矩阵
2015-12-11 22:23
381 查看
看到机器学习算法时,注意到了shape计算矩阵的方法接下来就讲讲我的理解吧
>>> from numpy import * >>> import operator >>> a =mat([[1,2,3],[5,6,9]]) >>> a matrix([[1, 2, 3], [5, 6, 9]])
>>> shape(a) (2, 3) >>> a.shape[0] #计算行数 2 >>> a.shape[1] #计算列数 3接下来是Python中的解释
Examples -------- >>> np.shape(np.eye(3)) (3, 3) >>> np.shape([[1, 2]]) (1, 2) >>> np.shape([0]) (1,) >>> np.shape(0) () >>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')]) >>> np.shape(a) (2,) >>> a.shape (2,)
相关文章推荐
- LeetCode Add Two Numbers
- 《利用python进行数据分析》读书笔记--第七章 数据规整化:清理、转换、合并、重塑(二)
- leetcode303-range sum query-python
- python学习---元祖和集合
- LeetCode Two Sum
- python django第一天
- 一篇文章入门Python生态系统(Python新手入门指导)
- 【Python】学习笔记六:循环
- python学习第七课 --面向对象
- python学习日记_第四天(ex9~11)
- python笔记(模块)
- Python--类-例子
- 常见的python的unitest用法
- Python 一行命令ftp服务器
- Python赋值语句与深拷贝、浅拷贝的区别
- Python: 消除print的自动换行
- python练习
- python 基本数据类型
- Python调用DLL
- python练习