Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is not feedable in tensorflow?

I've tried the following code. But I don't find what is not feedable in tensorflow. Could anybody show me what is not feedable?

#!/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)
like image 505
user1424739 Avatar asked Mar 14 '26 18:03

user1424739


1 Answers

All tensors are feedable (including the constants, as you can see), unless they are explicitly prevented from feeding via tf.Graph.prevent_feeding method. One can call this method directly or indirectly, for example, that's what tf.contrib.util.constant_value function does:

NOTE: If constant_value(tensor) returns a non-None result, it will no longer be possible to feed a different value for tensor. This allows the result of this function to influence the graph that is constructed, and permits static shape optimizations.

Sample code:

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

with tf.Session() as sess:
  print sess.graph.is_feedable(y)  # False!
like image 174
Maxim Avatar answered Mar 16 '26 16:03

Maxim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!