Skip to content

Commit

Permalink
hello world of tensorflow
Browse files Browse the repository at this point in the history
  • Loading branch information
LordSomen committed Aug 9, 2018
1 parent 18a020a commit bba2df0
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Tensorflow/tf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#%%
import tensorflow as tf
import time

t = time.time()
x = tf.Variable(7,name="x")
y = tf.Variable(2,name="y")
f = x*x*x + y + 2
t1 = time.time() - t
print(t1)

#%%

t = time.time()
sess = tf.Session()
sess.run(x.initializer)
sess.run(y.initializer)
t1 = time.time() - t
print(t1)

#%%
t = time.time()
result = sess.run(f)
print(result)
sess.close
t1 = time.time() - t
print(t1)

#%%
with tf.Session() as sess:
x.initializer.run()
y.initializer.run()
result = f.eval()
print(result)

#%%
init = tf.global_variables_initializer()
# prepare an init node
with tf.Session() as sess:
init.run() # actually initialize all the variables
result = f.eval()
print(result)

#%%
sess = tf.InteractiveSession()
init.run()
result = f.eval()
print(result)
sess.close()

0 comments on commit bba2df0

Please sign in to comment.