In [3]:
import tensorflow as tf
graph = tf.get_default_graph()
graph.get_operations()
for op in graph.get_operations():
    print(op.name)

In [4]:
sess = tf.Session()
sess.close()

In [5]:
with tf.Session() as sess:
    sess.run(f)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-6e51c8f22dfb> in <module>()
      1 with tf.Session() as sess:
----> 2     sess.run(f)

NameError: name 'f' is not defined

In [6]:
a = tf.constant(1.0)
a
print(a)


Tensor("Const:0", shape=(), dtype=float32)

In [2]:
with tf.Session() as sess:
    print(sess.run(a))


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-58c673e3adfb> in <module>()
----> 1 with tf.Session() as sess:
      2     print(sess.run(a))

NameError: name 'tf' is not defined

In [11]:
b = tf.Variable(2.0, name = "test_var")
b


Out[11]:
<tensorflow.python.ops.variables.Variable at 0x10652c4d0>

In [12]:
init_op = tf.global_variables_initializer()

In [1]:
with tf.Session() as sess:
    sess.run(init_op)
    print(sess.run(b))


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-3daf557fa253> in <module>()
----> 1 with tf.Session() as sess:
      2     sess.run(init_op)
      3     print(sess.run(b))

NameError: name 'tf' is not defined

In [ ]:
graph = tf.get_default_graph()
for op in graph.get_operations():
    print(op.name)


Const
Const_1
test_var/initial_value
test_var
test_var/Assign
test_var/read
init

In [15]:
a = tf.placeholder("float")
b = tf.placeholder("float")
y = tf.multiply(a, b)
feed_dict = {a:2, b:3}
with tf.Session() as sess:
    print(sess.run(y, feed_dict))


6.0

In [16]:
w = tf.Variable(tf.random_normal([784, 10], stddev=0.01))

In [22]:
b = tf.Variable([10,20,30,40,50,60], name='t')
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    print(sess.run(tf.reduce_mean(b)))


35

In [26]:
a =[[0.1, 0.2, 0.3],
[20, 2, 3]]
b = tf.Variable(a, name='b')
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    print(sess.run(tf.argmax(b, 1)))


[2 0]

In [ ]: