기본 콘텐츠로 건너뛰기

라벨이 차원증가인 게시물 표시

[matplotlib]quiver()함수

[numpy] stack 함수

stack 함수 두 개이상의 배열 또는 list, DataFrame 등의 유사한 자료형의 객체들을 결합하기 위해 사용합니다. 결합하는 과정에서 새로운 축이 첨가 됩니다. np.stack((x,y,...), axis=0) 배열(x, y, …)들은 동일한 차원과 형태(shape) x, y등의 각 객체에 axis=정수로 지정된 축이 첨가되고 그 축을 기준으로 결합 인수 axis에 전달하는 정수는 축인덱스로 음이 아닌 양수 음수인 경우는 역인덱스, 예를 들어 -1인 경우 마지막 축을 의미 axis=0이 기본값 예를 들어 1차원과 2차원 객체들의 결합의 결과는 다음과 같이 전개됩니다. \begin{align} &\text{shape of x and y}:\, (3,)\\ &\begin{aligned} \text{axis = 0}\quad&\quad1\times 3\\&\underline{+\,1\times 3}\\& \quad2 \times 3 \end{aligned}\quad \begin{aligned} \text{axis = 1}\quad&\quad3\times 1\\&\underline{+\,3\times 1}\\& \quad3 \times 2\end{aligned} \end{align} \begin{align} &\text{shape of x and y}:\, 3\times 4\\ &\begin{aligned} \text{axis = 0}\quad&\quad1\times 3\times 4\\&\underline{+\,1\times 3\times 4}\\& \quad2 \times 3\times 4 \end{aligned}\\ &\begin{aligned} \text{axis = 1}\quad&\quad3\times 1\times 4\\...