Skip to content

Instantly share code, notes, and snippets.

@Ouwen
Created July 26, 2018 04:28
Show Gist options
  • Save Ouwen/7ccf173181f0fd7759698a6b971a3d70 to your computer and use it in GitHub Desktop.
Save Ouwen/7ccf173181f0fd7759698a6b971a3d70 to your computer and use it in GitHub Desktop.
import tensorflow as tf
g1 = tf.Graph()
with g1.as_default():
my_input = tf.constant([-1,0,1], dtype=tf.float16, name="input")
my_printed_input = tf.Print(my_input, [], message="Running the graph", name="print")
a = tf.square(my_printed_input, name="A")
b = tf.cos(a, name="B")
c = tf.sin(a, name="C")
d = tf.add(b, c, name="D")
e = tf.floor(b, name="E")
f = tf.sqrt(d, name="F")
sess = tf.Session(graph=g1);
sess.run({
"A": g1.get_operation_by_name("A").outputs,
"B": g1.get_operation_by_name("B").outputs,
"C": g1.get_operation_by_name("C").outputs,
"D": g1.get_operation_by_name("D").outputs,
"E": g1.get_operation_by_name("E").outputs,
"F": g1.get_operation_by_name("F").outputs
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment