부스트캠프 AI Tech 3기 Pre-Course [6]-2 Numpy : reshape, creation, operation, math, performance
reshape array의 shape의 크기를 변경하는데, element의 갯수는 동일하다. import numpy as np a=np.array([[1,2,3,4],[2,3,4,5]]) print(a.shape) # (2,4) print(a.reshape(8,)) # >>[1 2 3 4 2 3 4 5] print(a.reshape(-1,2)) # [[1 2] # [3 4] # [2 3] # [4 5]] print(a.reshape(2,-1,2)) # [[[1 2] # [3 4]] # # [[2 3] # [4 5]]] 어차피 정해진 element수는 계속해서 같기 때문에 나머지 하나를 -1 로 두면 알아서 남은 만큼으로 만들어준다. 이 코드에서는 a=a.reshape~~ 이렇게 할당이 일어나지 않았기 때..