• 欢迎访问IT乐园(o゚▽゚)o
  • 推荐使用最新版火狐浏览器和Chrome浏览器访问本网站。

python之numpy模块

python fhy 1年前 (2017-04-14) 631次浏览 0个评论 扫描二维码
文章目录[隐藏]

1)numpy.mat

将数组转化为矩阵

numpy.mat(data, dtype=None)
Interpret the input as a matrix.

Unlike matrix, asmatrix does not make a copy if the input is already a matrix or an ndarray. Equivalent to matrix(data, copy=False).

 

2)numpy.shape

shape(a)
Return the shape of an array.

Parameters


a : array_like
Input array.

Returns


shape : tuple of ints
The elements of the shape tuple give the lengths of the
corresponding array dimensions.

See Also


alen
ndarray.shape : Equivalent array method.

Examples

3)numpy.eye

eye(N, M=None, k=0, dtype=<class ‘float’>)
Return a 2-D array with ones on the diagonal and zeros elsewhere.

Parameters


N : int
Number of rows in the output.
M : int, optional
Number of columns in the output. If None, defaults to N.
k : int, optional
Index of the diagonal: 0 (the default) refers to the main diagonal,
a positive value refers to an upper diagonal, and a negative value
to a lower diagonal.
dtype : data-type, optional
Data-type of the returned array.

Returns


I : ndarray of shape (N,M)
An array where all elements are equal to zero, except for the k-th
diagonal, whose values are equal to one.

See Also


identity : (almost) equivalent function
diag : diagonal 2-D array from a 1-D array specified by the user.

Examples


4)np.clip

5)numpy.dot

6)numpy.power

 

生成从 0 到 100 的 10*10 随机数组

(为学习 numpy 持续更新)


IT 乐园 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:python 之 numpy 模块
喜欢 (0)
关于作者:
九零后挨踢男
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址