Challenge - 5 Problems
TensorFlow Execution Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding TensorFlow Execution Modes
Which of the following statements correctly describes TensorFlow's eager execution mode?
Attempts:
2 left
💡 Hint
Think about how TensorFlow runs operations step-by-step versus building a graph.
✗ Incorrect
Eager execution runs operations immediately and returns actual values, which helps with debugging and interactive development. The graph mode builds a static graph first.
❓ Predict Output
intermediate2: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)
Attempts:
2 left
💡 Hint
Eager execution returns a Tensor object with value and metadata.
✗ Incorrect
With eager execution, operations return tf.Tensor objects showing the value, shape, and type immediately.
❓ Model Choice
advanced2: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?
Attempts:
2 left
💡 Hint
Consider which mode allows TensorFlow to optimize and parallelize computations.
✗ Incorrect
Graph execution mode builds a static graph that TensorFlow can optimize and run efficiently, especially for large models.
❓ Hyperparameter
advanced2:00remaining
Effect of tf.function on Execution Mode
What does the @tf.function decorator do to a Python function in TensorFlow?
Attempts:
2 left
💡 Hint
Think about how TensorFlow can speed up Python code by changing its execution style.
✗ Incorrect
@tf.function compiles a Python function into a TensorFlow graph, improving performance by optimizing and running it as a graph.
🔧 Debug
expert2: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)
Attempts:
2 left
💡 Hint
Consider the types of inputs and how TensorFlow operations handle them inside tf.function.
✗ Incorrect
tf.function automatically converts Python scalars like integers to tf.constant tensors during tracing. No error occurs, and it prints tf.Tensor(5, shape=(), dtype=int32).