Loading

Python:numpy中shape和reshape的用法

>>> w=np.zeros((5,6))
>>> w
array([[ 0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.]])

 

>>> w.shape[0]
5

>>> w.shape[1]
6

w是一个5行6列的矩阵

w.shape[0]返回的是w的行数

w.shape[1]返回的是w的列数

 

posted @ 2018-03-07 00:09  RainDavi  阅读(392)  评论(0编辑  收藏  举报