0
0
TensorFlowml~20 mins

TensorFlow vs PyTorch comparison - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
TensorFlow vs PyTorch 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 TensorFlow and PyTorch

Which statement best describes the main difference in how TensorFlow and PyTorch execute operations?

ATensorFlow uses dynamic computation graphs, while PyTorch uses static computation graphs.
BTensorFlow uses static computation graphs, while PyTorch uses dynamic computation graphs.
CBoth TensorFlow and PyTorch use only static computation graphs.
DBoth TensorFlow and PyTorch use only dynamic computation graphs.
Attempts:
2 left
💡 Hint

Think about when the computation graph is built and executed in each framework.

Predict Output
intermediate
2:00remaining
Output shape after PyTorch tensor operation

What is the shape of the tensor y after running this PyTorch code?

TensorFlow
import torch
x = torch.randn(3, 4)
y = x.view(-1, 2)
print(y.shape)
Atorch.Size([6, 2])
Btorch.Size([3, 2])
Ctorch.Size([2, 6])
Dtorch.Size([4, 3])
Attempts:
2 left
💡 Hint

Remember that view(-1, 2) reshapes the tensor to have 2 columns and infers the number of rows.

Model Choice
advanced
2:00remaining
Choosing framework for research with frequent model changes

You are a researcher who needs to frequently change and debug your neural network models. Which framework is generally better suited for this purpose?

ATensorFlow, because its static graphs make debugging easier.
BPyTorch, because it requires less memory for static graphs.
CTensorFlow, because it has better GPU support for research.
DPyTorch, because its dynamic graphs allow easier model changes and debugging.
Attempts:
2 left
💡 Hint

Consider which framework builds the computation graph on the fly.

Hyperparameter
advanced
2:00remaining
Default behavior difference in training mode between TensorFlow and PyTorch

When switching between training and evaluation modes, which statement correctly describes the default behavior difference between TensorFlow and PyTorch?

AIn PyTorch, you must call <code>model.train()</code> or <code>model.eval()</code> to toggle training mode; TensorFlow manages this automatically during training and inference.
BIn TensorFlow, layers like dropout are always active unless explicitly disabled; in PyTorch, dropout is disabled by default.
CBoth TensorFlow and PyTorch require manual toggling of training and evaluation modes for layers like dropout.
DTensorFlow disables dropout during training by default, while PyTorch enables it during evaluation.
Attempts:
2 left
💡 Hint

Think about how each framework handles layers like dropout during training and evaluation.

Metrics
expert
2:00remaining
Comparing model accuracy reporting between TensorFlow and PyTorch

You train a classification model in both TensorFlow and PyTorch using the same dataset and architecture. After training, you want to compare accuracy metrics. Which statement is true about how accuracy is typically computed and reported in these frameworks?

ABoth TensorFlow and PyTorch provide built-in accuracy metrics that automatically compute overall accuracy without manual aggregation.
BPyTorch's accuracy metric automatically averages accuracy over batches, while TensorFlow requires manual calculation of accuracy over the entire dataset.
CTensorFlow's built-in accuracy metric automatically averages accuracy over batches, while PyTorch requires manual calculation of accuracy over the entire dataset.
DNeither TensorFlow nor PyTorch provide built-in accuracy metrics; accuracy must always be computed manually.
Attempts:
2 left
💡 Hint

Consider how metrics are implemented and used in each framework's training loops.