나는 tensorflow에서 tf.rank 함수를 이해하려고합니다. 문서 here에서 계급이 텐서의 별개 요소의 수를 반환해야한다는 것을 이해했습니다.Tensorflow의 tf.rank 함수
여기 x와 가중치는 각각 2 개의 뚜렷한 2 * 2 텐서이고 각각에 4 개의 뚜렷한 요소가 있습니다. 그러나, 랭크() 함수의 출력은 :
텐서 ("등급 : 0"형상 =() DTYPE = INT32) 텐서 ("RANK_1 0"형상 =() DTYPE = INT32)
또한 텐서 x에 대하여, I는 float32 텐서하지만 랭크()로 여전히 INT32 출력으로 변환 ndarray DTYPE = 플로트와 tf.constant()를 사용 하였다.
g = tf.Graph()
with g.as_default():
weights = tf.Variable(tf.truncated_normal([2,2]))
x = np.asarray([[1 , 2], [3 , 4]])
x = tf.constant(x, dtype = tf.float32)
y = tf.matmul(weights, x)
print (tf.rank(x), tf.rank(weights))
with tf.Session(graph = g) as s:
tf.initialize_all_variables().run()
print (s.run(weights), s.run(x))
print (s.run(y))
출력을 어떻게 해석해야합니까?
감사합니다. Danevskyi. 그건 의미가 있습니다. session.run()의 일부로 실행해야한다고 생각합니다. tensorflow에 익숙해지기 – Abhi