def main(): epoch_number = 100000 print("Benchmark scenario: {}, epoch: {}".format("multiple operation", epoch_number)) sess = tf.Session() a = tf.constant(10.0) b = tf.constant(32.0) c = a * b start_time = time.time() for i in range(epoch_number): sess.run(c) end_time = time.time() print("Run time(s): {}".format(end_time - start_time)) # Almost 13.787735939
def main(): a = tf.placeholder(tf.float32) b = tf.constant(32.0) c = tf.add(a, b) sess = tf.Session() print(sess.run(c, feed_dict={a: 10})) print(sess.run(c, feed_dict={a.name: 10}))
def main(): sess = tf.Session() hello = tf.constant("Hello, MiniFlow!") print(sess.run(hello)) # "Hello, MiniFlow!" a = tf.constant(10) b = tf.constant(32) c = tf.add(a, b) print(sess.run(c)) # 42 sess = tf.Session() a = tf.placeholder(tf.float32) b = tf.constant(32.0) c = tf.add(a, b) print(sess.run(c, feed_dict={a: 10.0})) print(sess.run(c, feed_dict={a.name: 10.0}))
def main(): sess = tf.Session() # Add a = tf.constant(32.0) b = tf.constant(10.0) c = a + b print(sess.run(c)) # Should be 42.0 # Minus c = a - b print(sess.run(c)) # Should be 22.0 # Multiple c = a * b print(sess.run(c)) # Should be 320.0 # Divide c = a / b print(sess.run(c)) # Should 3.2