本文簡要介紹 python 語言中  numpy.stack  的用法。
- 用法:- numpy.stack(arrays, axis=0, out=None)
- 沿新軸加入一係列數組。 - axis參數指定新軸在結果維度中的索引。例如,如果- axis=0它將是第一個維度,如果- axis=-1它將是最後一個維度。- arrays: 數組 序列
- 每個數組必須具有相同的形狀。 
- axis: 整數,可選
- 結果數組中輸入數組沿其堆疊的軸。 
- out: ndarray,可選
- 如果提供,則放置結果的目的地。形狀必須正確,與未指定 out 參數時返回的堆棧相匹配。 
 
- stacked: ndarray
- 堆疊數組比輸入數組多一維。 
 
 - 參數:- 返回:- 例子:- >>> arrays = [np.random.randn(3, 4) for _ in range(10)] >>> np.stack(arrays, axis=0).shape (10, 3, 4)- >>> np.stack(arrays, axis=1).shape (3, 10, 4)- >>> np.stack(arrays, axis=2).shape (3, 4, 10)- >>> a = np.array([1, 2, 3]) >>> b = np.array([4, 5, 6]) >>> np.stack((a, b)) array([[1, 2, 3], [4, 5, 6]])- >>> np.stack((a, b), axis=-1) array([[1, 4], [2, 5], [3, 6]])
相關用法
- Python numpy std用法及代碼示例
- Python numpy stride_tricks.sliding_window_view用法及代碼示例
- Python numpy searchsorted用法及代碼示例
- Python numpy shape用法及代碼示例
- Python numpy scimath.log用法及代碼示例
- Python numpy signbit用法及代碼示例
- Python numpy setdiff1d用法及代碼示例
- Python numpy seterr用法及代碼示例
- Python numpy sort用法及代碼示例
- Python numpy scimath.logn用法及代碼示例
- Python numpy square用法及代碼示例
- Python numpy scimath.log2用法及代碼示例
- Python numpy sum用法及代碼示例
- Python numpy spacing用法及代碼示例
- Python numpy seterrobj用法及代碼示例
- Python numpy squeeze用法及代碼示例
- Python numpy scimath.arccos用法及代碼示例
- Python numpy shares_memory用法及代碼示例
- Python numpy s_用法及代碼示例
- Python numpy swapaxes用法及代碼示例
- Python numpy sctype2char用法及代碼示例
- Python numpy show_config用法及代碼示例
- Python numpy set_printoptions用法及代碼示例
- Python numpy source用法及代碼示例
- Python numpy save用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.stack。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
