本文簡要介紹 python 語言中  numpy.ma.expand_dims  的用法。
- 用法:- ma.expand_dims(a, axis)
- 展開數組的形狀。 - 插入一個新軸,該軸將出現在展開的數組形狀中的軸位置。 - a: array_like
- 輸入數組。 
- axis: int 或整數元組
- 放置新軸(或多個軸)的擴展軸中的位置。 
 
- result: ndarray
- 視圖隨著維度數量的增加而增加。 
 
 - 參數:- 返回:- 例子:- >>> x = np.array([1, 2]) >>> x.shape (2,)- 以下等效於 - x[np.newaxis, :]或- x[np.newaxis]:- >>> y = np.expand_dims(x, axis=0) >>> y array([[1, 2]]) >>> y.shape (1, 2)- 以下等價於 - x[:, np.newaxis]:- >>> y = np.expand_dims(x, axis=1) >>> y array([[1], [2]]) >>> y.shape (2, 1)- axis也可能是一個元組:- >>> y = np.expand_dims(x, axis=(0, 1)) >>> y array([[[1, 2]]])- >>> y = np.expand_dims(x, axis=(2, 0)) >>> y array([[[1], [2]]])- 請注意,某些示例可能使用 - None而不是- np.newaxis。這些是相同的對象:- >>> np.newaxis is None True
相關用法
- Python numpy ma.empty_like用法及代碼示例
- Python numpy ma.empty用法及代碼示例
- Python numpy ma.indices用法及代碼示例
- Python numpy ma.zeros用法及代碼示例
- Python numpy ma.diff用法及代碼示例
- Python numpy ma.mask_rowcols用法及代碼示例
- Python numpy ma.where用法及代碼示例
- Python numpy ma.zeros_like用法及代碼示例
- Python numpy ma.notmasked_contiguous用法及代碼示例
- Python numpy ma.concatenate用法及代碼示例
- Python numpy ma.apply_along_axis用法及代碼示例
- Python numpy ma.compress_rowcols用法及代碼示例
- Python numpy ma.vstack用法及代碼示例
- Python numpy ma.atleast_3d用法及代碼示例
- Python numpy ma.count用法及代碼示例
- Python numpy ma.fix_invalid用法及代碼示例
- Python numpy ma.mean用法及代碼示例
- Python numpy ma.argmax用法及代碼示例
- Python numpy ma.hstack用法及代碼示例
- Python numpy ma.isMA用法及代碼示例
- Python numpy ma.argmin用法及代碼示例
- Python numpy ma.asarray用法及代碼示例
- Python numpy ma.set_fill_value用法及代碼示例
- Python numpy ma.is_mask用法及代碼示例
- Python numpy ma.is_masked用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.ma.expand_dims。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
