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

# python之numpy模块

3年前 (2017-04-14) 1300次浏览

## 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.

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.

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

Examples

# （为学习 numpy 持续更新）

IT 乐园 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 