4
import tensorflow as tf
array = tf.Variable(tf.random_normal([10]))
i = tf.constant(0)
l = []
def cond(i,l):
return i < 10
def body(i,l):
temp = tf.gather(array,i)
l.append(temp)
return i+1,l
index,list_vals = tf.while_loop(cond, body, [i,l])
위의 코드에서 설명한 것과 비슷한 방식으로 텐서 배열을 처리하고 싶습니다. while 루프의 본문에서는 요소를 기준으로 배열을 처리하여 일부 기능을 적용하려고합니다. 데모를 위해 작은 코드 스 니펫을 제공했습니다. 그러나 다음과 같은 오류 메시지가 나타납니다.루프 실행 중 Tensorflow
ValueError: Number of inputs and outputs of body must match loop_vars: 1, 2
이 문제를 해결할 수있는 도움이 필요합니다.
덕분에 문서를 인용