欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python中shape計(jì)算矩陣的方法示例

 更新時(shí)間:2017年04月21日 14:15:06   作者:我要的shine  
這篇文章主要介紹了Python中shape計(jì)算矩陣的方法,涉及Python數(shù)學(xué)運(yùn)算相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下

本文實(shí)例講述了Python中shape計(jì)算矩陣的方法。分享給大家供大家參考,具體如下:

看到機(jī)器學(xué)習(xí)算法時(shí),注意到了shape計(jì)算矩陣的方法接下來就講講我的理解吧

>>> 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] #計(jì)算行數(shù)
2
>>> a.shape[1] #計(jì)算列數(shù)
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,)

更多關(guān)于Python相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python Socket編程技巧總結(jié)》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python入門與進(jìn)階經(jīng)典教程》及《Python文件與目錄操作技巧匯總

希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論