0
0
TensorFlowml~20 mins

TensorFlow architecture (eager vs graph execution) - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
TensorFlow Execution Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding TensorFlow Execution Modes
Which of the following statements correctly describes TensorFlow's eager execution mode?
AEager execution builds a static computation graph that must be compiled before running.
BEager execution runs operations immediately and returns concrete values, making debugging easier.
CEager execution requires manual session management to run operations.
DEager execution disables automatic differentiation in TensorFlow.
Attempts:
2 left
💡 Hint
Think about how TensorFlow runs operations step-by-step versus building a graph.
Predict Output
intermediate
2:00remaining
Output of TensorFlow Eager Execution Code
What is the output of this TensorFlow code snippet when eager execution is enabled?
TensorFlow
import tensorflow as tf
x = tf.constant(3)
y = tf.constant(4)
z = x * y
print(z)
Atf.Tensor(12, shape=(), dtype=int32)
B<tf.Tensor 'Mul:0' shape=() dtype=int32>
C12
DError: TensorFlow graph not initialized
Attempts:
2 left
💡 Hint
Eager execution returns a Tensor object with value and metadata.
Model Choice
advanced
2:00remaining
Choosing Execution Mode for Performance
You want to train a large neural network model efficiently in TensorFlow. Which execution mode should you choose to maximize performance?
AEager execution mode, because it runs operations immediately for faster debugging.
BGraph execution mode, because it disables automatic differentiation.
CGraph execution mode, because it compiles the computation graph for optimized performance.
DEager execution mode, because it disables GPU acceleration.
Attempts:
2 left
💡 Hint
Consider which mode allows TensorFlow to optimize and parallelize computations.
Hyperparameter
advanced
2:00remaining
Effect of tf.function on Execution Mode
What does the @tf.function decorator do to a Python function in TensorFlow?
AIt converts the function into a TensorFlow graph for faster execution.
BIt disables TensorFlow's automatic differentiation inside the function.
CIt forces the function to run eagerly without building a graph.
DIt converts all tensors inside the function to NumPy arrays.
Attempts:
2 left
💡 Hint
Think about how TensorFlow can speed up Python code by changing its execution style.
🔧 Debug
expert
2:00remaining
Identifying Error in Mixed Execution Code
What error will this TensorFlow code raise when eager execution is enabled by default?
TensorFlow
import tensorflow as tf
@tf.function
def add_tensors(x, y):
    return x + y

result = add_tensors(tf.constant(2), 3)
print(result)
ARuntimeError: Eager execution must be disabled to use tf.function
BValueError: tf.function cannot accept Python integers as arguments
CTypeError: Unsupported operand type(s) for +: 'Tensor' and 'int'
DNo error, prints tf.Tensor(5, shape=(), dtype=int32)
Attempts:
2 left
💡 Hint
Consider the types of inputs and how TensorFlow operations handle them inside tf.function.