Graphs inside a function (Tensorflow)

Code example:

     def build_graph():
          g = tf.Graph()
          with g.as_default():
              a = tf.placeholder(tf.int8, name="a")
              b = tf.add(a, tf.constant(1, dtype=tf.int8), name="b")
          return g

     graph = build_graph()
     with tf.Session(graph=graph) as sess:
          feed = {"a:0": 3}
          print(sess.run("b:0", feed_dict=feed))
     
Manuel Cuevas

Manuel Cuevas

Hello, I'm Manuel Cuevas a Software Engineer with background in machine learning and artificial intelligence.

Recent post