python numpy np.full(shape, fill_value, dtype=None, order='C')函数 以指定数值填充指定形状的数组
生活随笔
收集整理的這篇文章主要介紹了
python numpy np.full(shape, fill_value, dtype=None, order='C')函数 以指定数值填充指定形状的数组
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
def full(shape, fill_value, dtype=None, order='C'):"""Return a new array of given shape and type, filled with `fill_value`.返回具有給定形狀和類型的新數(shù)組,并填充“ fill_value”。Parameters----------shape : int or sequence of intsShape of the new array, e.g., ``(2, 3)`` or ``2``.形狀:整數(shù)或整數(shù)序列新數(shù)組的形狀,例如``(2,3)``或``2''。fill_value : scalarFill value.dtype : data-type, optionalThe desired data-type for the array The default, `None`, means`np.array(fill_value).dtype`.order : {'C', 'F'}, optionalWhether to store multidimensional data in C- or Fortran-contiguous(row- or column-wise) order in memory.fill_value:標量(就是純數(shù)值變量)填充值。dtype:數(shù)據(jù)類型,可選數(shù)組所需的數(shù)據(jù)類型默認值為“ None”,表示`np.array(fill_value).dtype`。順序:{'C','F'},可選是否以C-或Fortran連續(xù)存儲多維數(shù)據(jù)(按行或按列)順序在內(nèi)存中。Returns-------out : ndarrayArray of `fill_value` with the given shape, dtype, and order.具有給定形狀,dtype和順序的“ fill_value”數(shù)組。See Also--------full_like : Return a new array with shape of input filled with value.empty : Return a new uninitialized array.ones : Return a new array setting values to one.zeros : Return a new array setting values to zero.full_like:返回一個新數(shù)組,其輸入形狀填充有值???#xff1a;返回一個新的未初始化的數(shù)組。一:將新的數(shù)組設(shè)置值返回為一。零:將新的數(shù)組設(shè)置值返回零。Examples-------->>> np.full((2, 2), np.inf)array([[ inf, inf],[ inf, inf]])>>> np.full((2, 2), 10)array([[10, 10],[10, 10]])"""if dtype is None:dtype = array(fill_value).dtypea = empty(shape, dtype, order)multiarray.copyto(a, fill_value, casting='unsafe')return a
總結(jié)
以上是生活随笔為你收集整理的python numpy np.full(shape, fill_value, dtype=None, order='C')函数 以指定数值填充指定形状的数组的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何在C++中调用python程序?
- 下一篇: tensorflow-yolov3 yu