目录
1.numpy.array
函数原型:
numpy.array(object, dtype=None, *, copy=True, order='K', subok=False, ndmin=0, like=None)
参数解释:
- object:array_like。可以是list,ndarray等。
- dtype:data-type, optional
- copy:bool, optional。默认为true
- ndmin:int,可选参数。指定至少维度
2. numpy.arange
函数原型:
numpy.arange([start, ]stop, [step, ]dtype=None, *, like=None)
如果只传1个参数,分别为stop参数
如果只传2个参数,分别为start,stop参数
如果传3个参数,分别为start,stop,step参数
3.numpy.empty
函数原型:numpy.empty(shape, dtype=float, order='C', *, like=None)
函数说明:Return a new array of given shape and type, without initializing entries.
4.numpy.empty_like
函数原型:numpy.empty_like(prototype, dtype=None, order='K', subok=True, shape=None)
函数说明:Return a new array with the same shape and type as a given array.
5.numpy.eye
函数原型:numpy.eye(N, M=None, k=0, dtype=<class 'float'>, order='C', *, like=None)
函数说明:返回一个2维矩阵,对角线是1,其他位置为0。N:int,输出行数。M:int,输出列数,默认为N
6.numpy.identity
函数原型:numpy.identity(n, dtype=None, *, like=None)
函数说明:单位矩阵,n*n,对角线为1,其他位置为0。
参数解释:n:int,输出行数与列数
7.numpy.ones
函数原型:numpy.ones(shape, dtype=None, order='C', *, like=None)
函数说明:返回全是1的矩阵
8.numpy.ones_like
函数原型:numpy.ones_like(a, dtype=None, order='K', subok=True, shape=None)
函数说明:返回与输入矩阵相同的shape和dtype的全是1的矩阵
9.numpy.zeros
numpy.zeros(shape, dtype=float, order='C', *, like=None)
10.numpy.zeros_like
numpy.zeros_like(a, dtype=None, order='K', subok=True, shape=None)
11.numpy.full
numpy.full(shape, fill_value, dtype=None, order='C', *, like=None)
12.numpy.full_like
numpy.full_like(a, fill_value, dtype=None, order='K', subok=True, shape=None)
13.numpy.fromfile
函数原型:
numpy.fromfile(file, dtype=float, count=- 1, sep='', offset=0, *, like=None)
import numpy as np
np.random.seed(0)
arr = np.arange(3 * 4, dtype = np.int8).reshape((3, 4))
print(arr)
print(arr.dtype)
arr.tofile('arr.bin')
arr2 = np.fromfile('arr.bin', dtype = np.int8).reshape((3, 4))
print(arr2)