Unit 1: Building Models with TensorFlow - Practice Quiz
1 What is TensorFlow primarily used for?
2 Which organization originally developed TensorFlow?
3
Which command is commonly used to install TensorFlow with pip?
python install tensor
pip install tensorflow
pip create tensorflow
tensorflow setup package
4
Which Python statement commonly imports TensorFlow using the alias tf?
import tensorflow as tf
load tf from tensorflow and initialize every available machine learning component
from tensorflow run tf
include tensorflow as tf
5 What is the rank of a scalar tensor?
6 Which description best matches a rank-2 tensor?
7 What does a TensorFlow computation graph represent?
8 Which TensorFlow decorator can convert a Python function into a callable TensorFlow graph?
@tf.tensor
@tf.variable
@tf.optimizer
@tf.function
9 Which TensorFlow object is designed to store model parameters that can change during training?
tf.rank
tf.Variable
tf.constant
tf.shape
10 Which method can directly update the value stored in a TensorFlow variable?
assign()
rank()
compile()
reshape()
11 What is the main purpose of an optimizer during model training?
12 Which of the following is a commonly used TensorFlow optimizer?
13 Which TensorFlow operation changes a tensor's shape without changing its element values?
tf.random.normal()
tf.reduce_sum()
tf.argmax()
tf.reshape()
14 A tensor has shape . How many elements does it contain?
15 What is TensorBoard mainly used for?
16 Which training metric is commonly plotted in TensorBoard?
17 What is deep learning?
18 What is the basic computational unit of an artificial neural network?
19 Which task is a common application of deep learning in computer vision?
20 Which application commonly uses deep learning to understand human language?
21 A developer wants TensorFlow to automatically compute gradients of a loss with respect to model parameters. Which TensorFlow feature should be used?
tf.TensorArray
tf.saved_model
tf.data.Dataset
tf.GradientTape
22 Which TensorFlow component is most appropriate for creating an efficient input pipeline from a large collection of training samples?
tf.math
tf.summary
tf.keras.layers
tf.data.Dataset
23 A project requires a TensorFlow version that conflicts with another project's dependencies. What is the most appropriate solution?
24 After installing TensorFlow, which command best verifies that the package can be imported and reports its installed version?
python -c "import tensorflow; print(tensorflow.shape)"
python -c "import tensorflow as tf; print(tf.__version__)"
pip build tensorflow --version
python tensorflow --check-version
25
An image batch has tensor shape (32, 28, 28, 1). What are its rank and batch size?
26
Given tensor A with shape (4, 3) and tensor B with shape (3, 2), what is the shape of tf.matmul(A, B)?
(3, 3)
(3, 2)
(4, 2)
(4, 3)
27
A training function is repeatedly executed with tensors of the same shape and type. What is a likely benefit of decorating it with @tf.function?
28
A function decorated with @tf.function is called using inputs with many different shapes, causing repeated tracing. Which approach can reduce this retracing?
29 A model weight must be updated during training and saved in checkpoints. Which TensorFlow object is most appropriate?
tf.TensorSpec
tf.Variable
tf.constant
tf.Operation
30
Suppose w is a trainable tf.Variable, g is its gradient, and is the learning rate. Which statement performs a basic gradient-descent update?
g.assign_sub(eta * w)
w = tf.constant(eta * g)
w.assign_add(eta * g)
w.assign_sub(eta * g)
31 For a parameter value , gradient , and SGD learning rate , what is the updated parameter value?
32 A model has noisy and differently scaled gradients across parameters. Which optimizer is commonly chosen because it adapts learning rates using gradient moments?
33
A tensor has shape (2, 3, 4). Which target shape is valid for tf.reshape without adding or removing elements?
(4, 6)
(3, 9)
(2, 4, 4)
(5, 5)
34
An image batch uses NHWC shape (batch, height, width, channels). Which permutation changes it to NCHW order?
perm=[0, 3, 1, 2]
perm=[0, 2, 3, 1]
perm=[3, 0, 1, 2]
perm=[1, 2, 0, 3]
35 A researcher wants to compare training and validation loss over epochs in TensorBoard. What should be recorded?
36
TensorBoard opens successfully but shows no experiment data. The model wrote summaries to /tmp/run1. What should be checked first?
/tmp/run1 as its log directory
37 Why are nonlinear activation functions placed between layers of a deep neural network?
38 A neural network performs well on training data but poorly on unseen data. Which change is most directly intended to reduce this problem?
39 A system must identify pedestrians and draw a bounding box around each one in an image. Which deep learning task best matches this requirement?
40 A company wants to translate customer messages from one language into another while accounting for relationships between distant words. Which model family is especially suitable?
41
A TensorFlow function receives a tensor x and computes y = x * 2 + 1. When x has shape (32, 10), which statement best explains TensorFlow's behavior?
42 A project requires TensorFlow with GPU acceleration, but another project requires a different CUDA-compatible configuration. Which installation strategy most reliably prevents dependency conflicts?
43
A tensor has shape (8, 28, 28, 3) and represents a batch of color images. Which interpretation is correct under the conventional channels-last layout?
44
Given a with shape (2, 1, 4) and b with shape (3, 4), what is the shape of a + b if broadcasting succeeds?
(2, 3, 4)
(3, 2, 4)
(2, 1, 4)
45
A function decorated with @tf.function is called first with a tensor of shape (16, 10) and later with shape (32, 10). What is the most accurate consequence?
46
Inside a @tf.function, a Python if depends on a tensor-valued condition. Which implementation is generally required for graph-compatible control flow?
tf.cond or a tensor-aware control-flow construct
bool
47
A trainable parameter is created as a tf.Variable, but its update is performed using assign_sub outside the gradient tape. Which statement is correct?
48
Why should model weights generally be stored as tf.Variable objects rather than ordinary tensors?
49 For a parameter with gradient , how does Adam differ fundamentally from vanilla stochastic gradient descent?
50
A training step computes gradients for a model, but one gradient is None. Which cause is most plausible?
51 A model is trained with a learning rate that is too large. Which pattern most strongly indicates unstable optimization rather than ordinary underfitting?
52
A tensor has shape (64, 28, 28, 1) and must be fed into a dense layer that expects one feature vector per example. Which transformation is appropriate?
tf.reshape(x, [1, 64, 784])
tf.reshape(x, [64, 28, 28, 1, 1])
tf.reshape(x, [64, 28, 28])
tf.reshape(x, [64, 784])
53
For a tensor x with shape (2, 3, 4), which operation changes its shape to (2, 4, 3) while preserving the arrangement of values along the last two axes?
tf.expand_dims(x, axis=2)
tf.squeeze(x, axis=1)
tf.reshape(x, [2, 4, 3])
tf.transpose(x, perm=[0, 2, 1])
54
A tensor has shape (5, 1, 7, 1). Which operation produces shape (5, 7) without changing the values in the remaining dimensions?
tf.squeeze(x, axis=[1, 3])
tf.squeeze(x)
tf.reduce_sum(x, axis=1)
tf.reshape(x, [1, 35])
55 A TensorBoard scalar summary is written inside a training loop, but the dashboard shows only one point. Which issue is most likely?
56 Two training runs use the same TensorBoard log directory and identical tag names. What is the main visualization risk?
57 Why can adding more layers increase a network's representational power while still making optimization harder?
58 A classifier achieves 99% training accuracy but performs poorly on unseen data. Which intervention most directly targets the underlying generalization problem?
59 In a medical image classifier, a rare disease is associated with much higher cost for false negatives than false positives. Which design choice best reflects this requirement?
60 A vision model performs well on laboratory images but poorly on images captured by a different hospital. What is the most defensible first response?
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →