日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

python numpy.ones(shape, dtype=None, order=’C’) empty(shape[, dtype, order]) empty_like(a) 空数组 全1数组

發(fā)布時(shí)間:2025/3/19 python 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python numpy.ones(shape, dtype=None, order=’C’) empty(shape[, dtype, order]) empty_like(a) 空数组 全1数组 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

ones(shape[, dtype, order])
依據(jù)給定形狀和類型(shape[, dtype, order])返回一個(gè)新的元素全部為1的數(shù)組。

def ones(shape, dtype=None, order='C'):"""Return a new array of given shape and type, filled with ones.返回給定形狀和類型的新數(shù)組,并填充為1。Parameters----------shape : int or sequence of intsShape of the new array, e.g., ``(2, 3)`` or ``2``.新數(shù)組的形狀,例如``(2,3)``或``2''。dtype : data-type, optionalThe desired data-type for the array, e.g., `numpy.int8`. Default is`numpy.float64`.數(shù)組所需的數(shù)據(jù)類型,例如numpy.int8。 默認(rèn)值為numpy.float64。order : {'C', 'F'}, optional, default: CWhether to store multi-dimensional data in row-major(C-style) or column-major (Fortran-style) order inmemory.是否以行優(yōu)先(C樣式)或列優(yōu)先(Fortran樣式)的順序存儲(chǔ)多維數(shù)據(jù)在內(nèi)存中。Returns-------out : ndarrayArray of ones with the given shape, dtype, and order.具有給定形狀,dtype和順序的數(shù)組。See Also--------ones_like : Return an array of ones with shape and type of input.empty : Return a new uninitialized array.zeros : Return a new array setting values to zero.full : Return a new array of given shape filled with value.Examples-------->>> np.ones(5)array([ 1., 1., 1., 1., 1.])>>> np.ones((5,), dtype=int)array([1, 1, 1, 1, 1])>>> np.ones((2, 1))array([[ 1.],[ 1.]])>>> s = (2,2)>>> np.ones(s)array([[ 1., 1.],[ 1., 1.]])"""

參考文章1:Python—numpy模塊下函數(shù)介紹(一)numpy.ones、empty等

參考文章2:【python進(jìn)階】python動(dòng)態(tài)數(shù)組

總結(jié)

以上是生活随笔為你收集整理的python numpy.ones(shape, dtype=None, order=’C’) empty(shape[, dtype, order]) empty_like(a) 空数组 全1数组的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。