Numpy常用属性及方法
Numpy 一、属性: ndarray.shape 返回一个元组,里面是各个维度的size ndarray.ndim 返回数组的维度 ndarray.dtype 返回数组数据的类型 二、方法: np.array(x, dtype=complex) 接收一个数组, dtype指定数据类型, np.zeros( (3,4) ) 接收一个代表数组维度size的元组 np.ones((3,4)) 同上 np.arange(10, 30, 5) 返回一个起始为10,每次增加5,一直到30但不包括30的数组(本例返回[10, 15, 20, 25]),一般会跟reshape配合使用。 np.linspace( 0, 2, 9 ) 将0-2分为九份 numpy.random.rand(d0, d1, ..., dn) Create an array of the given shape and populate it with random samples from a uniform distribution(均匀分布) over [0, 1). numpy.random.randn(d0, d1...