0
0
PyTorchml~20 mins

PyTorch vs TensorFlow comparison - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PyTorch vs TensorFlow Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Key difference in execution style between PyTorch and TensorFlow
Which statement best describes the main difference in how PyTorch and TensorFlow execute operations?
ABoth PyTorch and TensorFlow exclusively use static computation graphs for faster execution.
BTensorFlow only supports eager execution, while PyTorch only supports static computation graphs.
CPyTorch uses eager execution by default, while TensorFlow originally used static graphs but now supports eager execution.
DPyTorch and TensorFlow both use eager execution only for training and static graphs only for inference.
Attempts:
2 left
💡 Hint
Think about how each framework builds and runs computations during model training.
Model Choice
intermediate
2:00remaining
Choosing framework for dynamic neural networks
You want to build a neural network where the structure changes during training based on input data. Which framework is generally better suited for this?
ATensorFlow, because it has better support for static graphs.
BPyTorch, because it supports dynamic computation graphs naturally.
CTensorFlow, because it is faster for all types of models.
DNeither, both frameworks handle dynamic graphs equally well.
Attempts:
2 left
💡 Hint
Consider which framework builds the graph on the fly during execution.
Metrics
advanced
2:00remaining
Comparing training speed metrics
You train the same model architecture on the same dataset using PyTorch and TensorFlow. Which metric would best compare their training speed fairly?
AMemory usage during inference.
BFinal accuracy after training completes.
CNumber of lines of code used to build the model.
DTotal training time in seconds for a fixed number of epochs.
Attempts:
2 left
💡 Hint
Focus on measuring speed, not accuracy or code complexity.
🔧 Debug
advanced
2:00remaining
Identifying cause of slower training in TensorFlow
You notice your TensorFlow model trains slower than the PyTorch version. Which of these is a likely cause?
ATensorFlow is running in graph mode without proper graph optimizations enabled.
BPyTorch does not support GPU acceleration, so it runs faster on CPU.
CTensorFlow models always use more memory, causing slowdowns.
DPyTorch uses static graphs which are faster by default.
Attempts:
2 left
💡 Hint
Think about how TensorFlow executes graphs and what might slow it down.
Predict Output
expert
3:00remaining
Output difference in simple tensor operation
What is the output of this PyTorch code snippet? import torch x = torch.tensor([1.0, 2.0, 3.0], requires_grad=True) y = x * 2 y = y.mean() y.backward() print(x.grad)
PyTorch
import torch
x = torch.tensor([1.0, 2.0, 3.0], requires_grad=True)
y = x * 2
y = y.mean()
y.backward()
print(x.grad)
Atensor([0.6667, 0.6667, 0.6667])
Btensor([2.0, 2.0, 2.0])
Ctensor([1.0, 1.0, 1.0])
DNone
Attempts:
2 left
💡 Hint
Recall how gradients are computed for mean of scaled tensor.