numpy array

³ÑÆÄÀÌ numpy array¸¦ ¾î¶»°Ô »ç¿ëÇÏ´ÂÁö ¾Ë¾Æ º»´Ù.

numpy ¹è¿­ÀÇ ±âº»ÀûÀÎ »ç¿ë¹ýÀº ´ÙÀ½°ú °°´Ù.
1Â÷¿ø ¹è¿­ÀÇ shape´Â (3, )ÀÌ´Ù.
2Â÷¿ø ¹è¿­ÀÇ shape´Â (2, 3)ÀÌ´Ù.
3Â÷¿ø ¹è¿­ÀÇ shape´Â (3, 2, 2)ÀÌ´Ù.

shape´Â Æ©Ç÷Π2Â÷ ¹è¿­À϶§´Â Çà, ¿­ÀÇ ±¸Á¶·Î Âø°¢ ÇÒ¼ö ÀÖ´Ù.
Å« ÁýÇÕ¿¡¼­ ÀÛÀº ÁýÇÕ ¼ø¼­·Î Æ©Çÿ¡ ÀÔ·ÂÇϴ°ɷΠ±â¾ïÇÑ´Ù.

import numpy as np

d1 = np.array([1, 2, 3])
print('D1->', d1.shape, '\n', d1)

print('------------------------------------------')
d2 = np.array([[1, 2, 3], [4, 5, 6]])
print('D2->', d2.shape, '\n', d2)

print('------------------------------------------')
d3 = np.array([[[1, 2], [3, 4]],
               [[5, 6], [7, 8]],
               [[9, 10], [11, 12]]])
print('D3->', d3.shape, '\n', d3)

°á°ú)
D1-> (3,)
 [1 2 3]
------------------------------------------
D2-> (2, 3)
 [[1 2 3]
 [4 5 6]]
------------------------------------------
D3-> (3, 2, 2)
 [[[ 1  2]
  [ 3  4]]

 [[ 5  6]
  [ 7  8]]

 [[ 9 10]
  [11 12]]]

reshape¸¦ ÀÌ¿ëÇØ ¹è¿­ÀÇ ÇüŸ¦ º¯°æÇÒ¼öµµ ÀÖ´Ù.
x = d3.reshape((6, 2))
print(x)

°á°ú)
[[ 1  2]
 [ 3  4]
 [ 5  6]
 [ 7  8]
 [ 9 10]
 [11 12]]