첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

■ Tensor 클래스의 get_shape 메소드를 사용해 랭크를 구하는 방법을 보여준다.

 

▶ 예제 코드 (PY)

import tensorflow as tf

scalarTensor     = tf.constant(100)
vectorTensor     = tf.constant([1, 2, 3, 4, 5])
matrixTensor     = tf.constant([[1, 2, 3], [4, 5, 6]])
cubeMatrixTensor = tf.constant([[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]])

scalarTensorShape     = scalarTensor.get_shape()
vectorTensorShape     = vectorTensor.get_shape()
matrixTensorShape     = matrixTensor.get_shape()
cubeMatrixTensorShape = cubeMatrixTensor.get_shape()

print(scalarTensorShape    )
print(vectorTensorShape    )
print(matrixTensorShape    )
print(cubeMatrixTensorShape)

[결과]

()
(5,)
(2, 3)
(3, 3, 1)
728x90
그리드형(광고전용)
Posted by icodebroker
,