Last active
May 9, 2017 07:21
-
-
Save diogoaurelio/5a0fd9501607ecf5b885b8cbecc95540 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 | |
a = tf.constant(1) | |
b = tf.constant(2) | |
c = a + b | |
with tf.Session() as session: | |
result = session.run(c) | |
print("Tensorflow supports simple summation with op: 'a + b = {}'".format(result)) | |
# Tensorflow supports simple summation with op: a + b = 3 | |
# Alternatively, since in practice we are just building a graph, | |
# we can explicitely declare to tensorflow how nodes are connected: | |
d = tf.add(a, b) | |
with tf.Session() as session: | |
result = session.run(d) | |
print("Tensorflow also supports simple summation via op: 'tf.add(a, b) = {}'".format(result)) | |
# Tensorflow also supports simple summation via op: tf.add(a, b) = 3 | |
# If you are confused by the | |
# with tf.Session() as session: | |
# statement, then do not worry, it is just a more concise manner to open and close automatically a session: | |
session = tf.Session() | |
result = session.run(d) | |
print("Run again the same computation graph: 'tf.add(a, b) = {}'".format(result)) | |
# Run again the same computation graph: tf.add(a, b) = 3 | |
session.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment