I have the following code that I have simplified:
class someClass():
def __init__(self):
self.u_pred, self.v_pred = self.fnc(self.x_tf, self.y_tf)
self.sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(allow_soft_placement=True,
log_device_placement=True))
def predict(self, x, y):
tf_dict = {self.x_tf: x, self.y_tf: y}
u = self.sess.run(self.u_pred, tf_dict)
v = self.sess.run(self.v_pred, tf_dict)
return u, v
Here how does sess.run able to fetch self.u_pred
and self.v_pred
when they are not even part of the graph as they havent been declared using tf.placeholder
?
After going through this question, my understanding is that session calls the tf.placeholder
and fetches the first argument passed and evaluates with the dictionary provided.
So in this case does self.sess.run(self.u_pred, tf_dict)
able to automatically find self.fnc()
and plugs in tf_dict = {self.x_tf: x, self.y_tf: y}
to auto-evaluate the function?