Created
May 31, 2017 19:19
-
-
Save diogoaurelio/aaeab834caea6759633cb1bde67e86f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
x = tf.Variable(3, name="x", dtype=tf.int16) | |
y = tf.Variable(4, name="y", dtype=tf.int16) | |
a = tf.constant(5, dtype=tf.int16) | |
b = tf.constant(10, dtype=tf.int16) | |
c = tf.constant(15, dtype=tf.int16) | |
op1 = x*x*y | |
op2 = a*b*c | |
f = op1 + op2 | |
init = tf.global_variables_initializer() | |
# How to evaluate op1, op2 and f efficiently, by asking tensorflow to evaluate | |
# all of them in one single graph | |
with tf.Session() as ses: | |
init.run() | |
op1_val, op2_val, f_val = ses.run([op1, op2, f]) | |
print("Result from computation of graph f_val is: {}".format(f_val)) | |
# Result from computation of graph f_val is: 786 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment