https://www.youtube.com/watch?v=ZYX0FaqUeN4
import numpy as np t = np.array([[[0,1,2], [3,4,5]], [[6,7,8],[9,10,11]]]) print(t) print("shape=",t.shape) print("----------------------") print("reshape#1") ar = np.reshape(t, (-1,3)) print(ar) print("shape=",ar.shape) print("----------------------") print("reshape#2") ar = np.reshape(ar, (-1,1,3)) print(ar) print("shape=",ar.shape) print("----------------------") print("squeeze") ar = np.squeeze([[0],[1],[2],[3]]) print( ar ) print( "shape=",ar.shape ) print("----------------------") print("expand_dims") ar = np.expand_dims([0, 1, 2], 1) print( ar ) print( "shape=",ar.shape )
In [1]:
[[[ 0 1 2]
[ 3 4 5]]
[[ 6 7 8]
[ 9 10 11]]]
shape= (2, 2, 3)
----------------------
reshape#1
[[ 0 1 2]
[ 3 4 5]
[ 6 7 8]
[ 9 10 11]]
shape= (4, 3)
----------------------
reshape#2
[[[ 0 1 2]]
[[ 3 4 5]]
[[ 6 7 8]]
[[ 9 10 11]]]
shape= (4, 1, 3)
----------------------
squeeze
[0 1 2 3]
shape= (4,)
----------------------
expand_dims
[[0]
[1]
[2]]
shape= (3, 1)
'Tensorflow Deep-Learning' 카테고리의 다른 글
텐서플로 1.x에서 모델 저장 및 불러오기 (0) | 2022.02.10 |
---|---|
FrozenLake-v1 텐서플로 Reinforcement Learning (0) | 2022.02.02 |
[텐서플로] 텐서플로2+케라스 => MNIST 테스트 (Single Layer Prediction) (0) | 2020.06.13 |
[텐서플로] Tensorflow2 케라스 클래스 계층구조 (0) | 2020.06.12 |
[텐서플로] C#에서 tensorflow 사용하기 (4) | 2020.06.10 |