import tensorflow as tf ############ # CONSTANT # ############ # Use variable_scope to modify names of all tensors in block. with tf.variable_scope("test"): # First constant. a = tf.constant(1, name="a") # Second constant. b = tf.constant(5, name="b") # Print names of our two constants. print(a.name) print(b.name) # We want to add 2 constants together. z = a + b # Run TensorFlow and solve for Z. result = tf.Session().run(z) print(result) ################ # PLACEHOLDERS # ################ # Two constants. a = tf.constant(5) b = tf.constant(10) # Use placeholder to insert values into TensorFlow from Python code. c = tf.placeholder(tf.int32) # Add the two constants. # ... Then subtract the input value we use for the placeholder. z = a + b - c # Run TensorFlow. # ... Use the value 5 for the placeholder C. result = tf.Session().run(z, {c: 2}) # This is 5 plus 10 minus 2. print(result) ########### # DROPOUT # ########### x = [1., 2., 1., 4., 1.] # Compute dropout on our tensor. result = tf.nn.dropout(x, 0.75) session = tf.Session() print(session.run(result))