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
그리드형(광고전용)
'Python > tensorflow' 카테고리의 다른 글
[PYTHON/TENSORFLOW] Variable 클래스 : 변수 사용하기 (0) | 2018.07.29 |
---|---|
[PYTHON/TENSORFLOW] convert_to_tensor 함수 : 텐서 구하기 (0) | 2018.07.29 |
[PYTHON/TENSORFLOW] InteractiveSession 클래스 사용하기 (0) | 2018.07.29 |
[PYTHON/TENSORFLOW] Variable 클래스 : 변수 사용하기 (0) | 2018.07.29 |
[PYTHON/TENSORFLOW] constant 함수 : 상수 만들기 (0) | 2018.07.29 |
[PYTHON/TENSORFLOW] placeholder 함수 사용하기 (0) | 2018.07.29 |
[PYTHON/TENSORFLOW] 다층 퍼셉트론 신경망 만들기 (MNIST) (0) | 2018.07.09 |
[PYTHON/TENSORFLOW] 단일 계층 퍼셉트론 신경망 만들기 (MNIST) (0) | 2018.07.09 |
[PYTHON/TENSORFLOW] K-평균 군집화(K-Means Clustering) 알고리즘 사용하기 (0) | 2018.07.08 |
[PYTHON/TENSORFLOW] K-최근접 이웃(KNN, K-Nearest Neighbors) 알고리즘 사용하기 (0) | 2018.07.08 |