2017-12-14 4 views
1

다음 코드를 시도했습니다. 하지만 나는 tensorflow에서 공급할 수없는 것을 발견하지 못합니다. 아무도 피드 기능이없는 것을 보여줄 수 있습니까? 그들은 명시 적으로 tf.Graph.prevent_feeding 방법을 통해 공급하는 것을 방지하지 않는tensorflow에서 공급할 수없는 것은 무엇입니까?

#!/usr/bin/env python 
# vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8: 

import tensorflow as tf 

x = tf.Variable(3) 
y = tf.constant(3) 
z = tf.add(1, 2) 
with tf.Session() as sess: 
    print sess.graph.is_feedable(x) 
    print sess.graph.is_feedable(y) 
    print sess.graph.is_feedable(z) 

답변

2

모든 텐서는 (당신이 볼 수 있듯이, 상수 포함) 급송 있습니다. 하나는 예를 들어, 그 tf.contrib.util.constant_value 함수가 무엇을, 직접 또는 간접적으로이 메소드를 호출 할 수 있습니다

참고 : constant_value(tensor)는 비 None 결과를 반환하는 경우, 더 이상 tensor에 대해 다른 값을 공급 할 수 없습니다. 이를 통해이 함수의 결과가 구성된 그래프에 영향을 미치고 정적 모양 최적화가 허용됩니다.

샘플 코드 :

y = tf.constant(3) 
tf.contrib.util.constant_value(y) # 3 

with tf.Session() as sess: 
    print sess.graph.is_feedable(y) # False! 
관련 문제