# np.expand_dims() ###### tags: `python語法` ```python= import numpy as np a = np.array([[[1,2,3,4],[4,5,6,7]]]) a.shape (1, 2, 4) ``` np.expand_dims(a, axis=0)表示在0位置新增資料(增加維度) ```python= b = np.expand_dims(a, axis=0) b array([[[[1, 2, 3, 4], [4, 5, 6, 7]]]]), b.shape (1, 1, 2, 4) ``` np.expand_dims(a, axis=1)表示在1位置新增資料(增加維度) ```python= c = np.expand_dims(a, axis=1) c array([[[[1, 2, 3, 4], [4, 5, 6, 7]]]]), c.shpae (1, 1, 2, 4) ``` np.expand_dims(a, axis=2)表示在2位置新增資料(增加維度) ```python= d = np.expand_dims(a, axis=2) d array([[[[1, 2, 3, 4]], [[4, 5, 6, 7]]]]), d.shape (1, 2, 1, 4) ``` np.expand_dims(a, axis=3)表示在3位置新增資料(增加維度) ```python= e = np.expand_dims(a, axis=3) e array([[[[1], [2], [3], [4]], [[4], [5], [6], [7]]]]), e.shape (1, 2, 4, 1) ```