0
0
TensorFlowml~10 mins

TensorFlow architecture (eager vs graph execution) - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable eager execution in TensorFlow.

TensorFlow
import tensorflow as tf

tf.config.run_functions_eagerly([1])
Drag options to blanks, or click blank then click option'
AFalse
BNone
CTrue
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using False disables eager execution.
Passing None or 0 will not enable eager execution.
2fill in blank
medium

Complete the code to create a TensorFlow function that runs as a graph.

TensorFlow
import tensorflow as tf

@tf.function
def add(a, b):
    return a [1] b
Drag options to blanks, or click blank then click option'
A*
B+
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
Forgetting the decorator to create a graph function.
3fill in blank
hard

Fix the error in the code to print the result of a TensorFlow tensor in eager mode.

TensorFlow
import tensorflow as tf

a = tf.constant(5)
print([1])
Drag options to blanks, or click blank then click option'
Aa.numpy()
Ba.eval()
Ca.value()
Da.data()
Attempts:
3 left
💡 Hint
Common Mistakes
Using eval() which requires a session in graph mode.
Trying to use non-existent methods like value() or data().
4fill in blank
hard

Fill both blanks to create a TensorFlow graph function that multiplies and then adds two tensors.

TensorFlow
import tensorflow as tf

@tf.function
def compute(x, y):
    mul = x [1] y
    return mul [2] y
Drag options to blanks, or click blank then click option'
A*
B+
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of operations.
Using subtraction or division instead of addition.
5fill in blank
hard

Fill all three blanks to create a TensorFlow function that subtracts, divides, and then multiplies two tensors.

TensorFlow
import tensorflow as tf

@tf.function
def complex_op(a, b):
    sub = a [1] b
    div = sub [2] b
    return div [3] a
Drag options to blanks, or click blank then click option'
A-
B/
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of subtraction.
Mixing up division and multiplication operators.