Slide 9
Slide 9 text
Eager Execution (Define by Run)
Listing 1: graph (define-and-run)
1 >>> v1 = tf.constant(1)
2 >>> v2 = tf.constant(2)
3 >>> v3 = v1 + v2
4 >>> print(v3)
5 Tensor("add:0", shape=(), dtype=
int32)
6 >>> sess = tf.Session()
7 >>> print(sess.run(v3))
8 3
Listing 2: eager (define-by-run)
1 >>> v1 = tf.constant(1)
2 >>> v2 = tf.constant(2)
3 >>> v3 = v1 + v2
4 >>> print(v3)
5 tf.Tensor(3, shape=(), dtype=int32)
6 >>> print(v3.numpy())
7 3
9