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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python numpy hstack() from shape_base.py (将数组水平堆叠)

發布時間:2025/3/20 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python numpy hstack() from shape_base.py (将数组水平堆叠) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
def hstack(tup):"""Stack arrays in sequence horizontally (column wise).水平(按列)順序堆疊數組。This is equivalent to concatenation along the second axis, except for 1-Darrays where it concatenates along the first axis. Rebuilds arrays dividedby `hsplit`.這等效于沿第二個軸的串聯,除了一維數組沿第一個軸的串聯。 重建除以“ hsplit”的數組。This function makes most sense for arrays with up to 3 dimensions. Forinstance, for pixel-data with a height (first axis), width (second axis),and r/g/b channels (third axis). The functions `concatenate`, `stack` and`block` provide more general stacking and concatenation operations.此功能對最多3維的陣列最有意義。 例如,對于具有高度(第一軸),寬度(第二軸)和r / g / b通道(第三軸)的像素數據。 函數concatenate,stack和block提供了更常規的堆疊和串聯操作。Parameters----------tup : sequence of ndarraysThe arrays must have the same shape along all but the second axis,except 1-D arrays which can be any length.ndarray的序列除第二個軸外,所有陣列的形狀都必須相同,除了一維陣列可以是任意長度。Returns-------stacked : ndarrayThe array formed by stacking the given arrays.堆疊:ndarray通過堆疊給定數組形成的數組。See Also--------stack : Join a sequence of arrays along a new axis.沿新軸連接一系列數組。vstack : Stack arrays in sequence vertically (row wise).垂直(行)按順序堆疊數組。dstack : Stack arrays in sequence depth wise (along third axis).沿深度方向(沿第三軸)按順序堆疊數組。concatenate : Join a sequence of arrays along an existing axis.沿現有軸連接一系列數組。hsplit : Split array along second axis.沿第二個軸拆分數組。block : Assemble arrays from blocks.從塊組裝數組。Examples-------->>> a = np.array((1,2,3))>>> b = np.array((2,3,4))>>> np.hstack((a,b))array([1, 2, 3, 2, 3, 4])>>> a = np.array([[1],[2],[3]])>>> b = np.array([[2],[3],[4]])>>> np.hstack((a,b))array([[1, 2],[2, 3],[3, 4]])"""arrs = [atleast_1d(_m) for _m in tup]# As a special case, dimension 0 of 1-dimensional arrays is "horizontal"if arrs and arrs[0].ndim == 1:return _nx.concatenate(arrs, 0)else:return _nx.concatenate(arrs, 1)

總結

以上是生活随笔為你收集整理的python numpy hstack() from shape_base.py (将数组水平堆叠)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。