728x90
In [2]:
import numpy as np
In [4]:
test_matrix = [[1,2,3,4], [1,2,5,8]]
np.array(test_matrix).shape
Out[4]:
In [5]:
np.array(test_matrix).reshape(2, 2, 2)
Out[5]:
In [7]:
test = np.array(test_matrix).reshape(8,)
test
Out[7]:
In [9]:
test.reshape(-1, 1)
Out[9]:
In [11]:
np.array(test_matrix).reshape(2, 4).shape
Out[11]:
In [13]:
np.array(test_matrix).reshape(2, -1).shape
Out[13]:
In [15]:
np.array(test_matrix).reshape(2, 2, 2)
Out[15]:
In [17]:
np.array(test_matrix).reshape(2, 2, 2).shape
Out[17]:
Flatten은 n차원 행렬을 1차원 행렬로 바꿔주는 함수이다.
In [18]:
test_matrix = [[[1,2,3,4], [1,2,5,8]], [[1,2,3,4], [1,2,5,8]]]
np.array(test_matrix).flatten()
Out[18]:
728x90
'Numpy' 카테고리의 다른 글
[Numpy] Operation, Dot product, Broadcasting (0) | 2021.07.16 |
---|---|
[Numpy] Operation_function, Concatenate (0) | 2021.07.16 |
[Numpy] Arange, ones, zeros, empty, eye, identity, digonal, random (0) | 2021.07.16 |
[Numpy] Indexing, Slicing (0) | 2021.07.16 |
[Numpy] Array 생성 (0) | 2021.07.16 |