Deep Learning for Computer Vision
- 67Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What is a tensor in TensorFlow?
A multi-dimensional array: 0D scalar, 1D vector, 2D matrix, 3D or 4D tensor.
Or swipe the card
67 cards
What is a tensor in TensorFlow?
A multi-dimensional array: 0D scalar, 1D vector, 2D matrix, 3D or 4D tensor.
How do you create a constant tensor with a specific data type in TensorFlow?
Use
tf.constant(value, dtype=tf.float32)(or other types likeint64,bool,string).How can you create a tensor from a NumPy array?
Use
tf.convert_to_tensor(numpy_array)or simply pass it totf.constant.What do
tf.ones,tf.zeros,tf.eye, andtf.filldo?tf.onescreates a tensor of all ones;tf.zerosall zeros;tf.eyecreates an identity matrix;tf.fillcreates a tensor filled with a scalar value.How do you create a tensor with random values from a normal distribution?
Use
tf.random.normal(shape, mean=0.0, stddev=1.0).How do you create a tensor with random values from a uniform distribution?
Use
tf.random.uniform(shape, minval=0, maxval=1).What are tensor shape, rank, and size?
Shape is the tuple of dimensions; rank is the number of dimensions; size is the total number of elements.
How do you slice a tensor in TensorFlow?
Use standard Python slicing, e.g.,
tensor[0:2, 1:3]. Ellipsis (...) represents all remaining dimensions.What is broadcasting in TensorFlow?
Automatic expansion of dimensions when performing operations on tensors of different shapes, following NumPy broadcasting rules.
How do you perform matrix multiplication in TensorFlow?
Use
tf.linalg.matmul(a, b)or the@operator.What is a ragged tensor?
A tensor with variable-length dimensions, created with
tf.ragged.constant.What is a sparse tensor?
A tensor that stores only non-zero values and their indices, created with
tf.sparse.SparseTensor.How do you create a trainable variable in TensorFlow?
Use
tf.Variable(initial_value); it can be updated withassign,assign_add, orassign_sub.What are the steps in the machine learning lifecycle?
Define task, source data, prepare data, build model, train/optimize, measure performance, validate/test, take corrective measures.
What is the purpose of the
tf.keras.layers.Normalizationlayer?To normalize input features by subtracting mean and dividing by standard deviation; it can learn statistics via
adapt().What does the
Denselayer compute?Y=W⋅X+B where W is weight matrix, X is input, B is bias.
Name three regression loss functions and their characteristics.
MSE penalizes outliers heavily; MAE is robust to outliers; Huber Loss combines both (quadratic near zero, linear far away).
How does Stochastic Gradient Descent (SGD) update weights?
weight=weight−learning_rate×∂weight∂loss
Why is the learning rate important in gradient descent?
Too small leads to slow convergence; too large can cause divergence (loss to increase).
What is the typical dataset split for training, validation, and test?
80% training, 10% validation, 10% test.
How can you address underfitting in a regression model?
Increase model complexity: add more hidden layers, use activation functions (ReLU, sigmoid, tanh), increase neurons, add batch normalization.
What are the benefits of using
tf.data.Dataset?Efficient data loading, shuffling, batching, and prefetching for improved performance.
How is an image represented as a tensor in TensorFlow?
As a 3D tensor of shape (height, width, channels) with pixel values (e.g., 0-255 for RGB).
What are the typical preprocessing steps for image datasets?
Resize to a fixed size (e.g., 224x224), normalize pixel values by dividing by 255 (or using mean/std).
What is a convolutional layer and its key parameters?
It applies a filter (kernel) sliding over the input to produce feature maps. Key parameters: kernel size, stride, padding (valid or same).
What is the purpose of the ReLU activation function?
It introduces non-linearity by outputting max(0, x).
What does batch normalization do?
Normalizes the outputs of a layer to have zero mean and unit variance, stabilizing and accelerating training.
What is the function of a pooling layer (e.g., max pooling)?
Reduces spatial dimensions (height, width) of feature maps, decreasing computation and providing translation invariance.
What loss function is used for binary classification?
Binary Cross-Entropy.
Why are precision, recall, and F1-score important beyond accuracy?
They are crucial when class imbalance exists or when false negatives/positives have different costs.
How can you save and load a trained model in TensorFlow?
Use
model.save('path')andtf.keras.models.load_model('path'); weights can be saved separately withmodel.save_weights().What is the difference between the Sequential, Functional, and Model Subclassing APIs?
Sequential: simple linear stack. Functional: allows multiple inputs/outputs, shared layers, non-linear topologies. Model Subclassing: custom forward pass via
call()method.How do you create a custom layer in TensorFlow?
Subclass
tf.keras.layers.Layerand implement__init__,build, andcallmethods.What is the purpose of
tf.GradientTape?To record operations for automatic differentiation, enabling gradient computation for custom training loops.
What is the difference between eager execution and graph execution in TensorFlow?
Eager: operations run immediately, easier debugging. Graph: builds a computational graph for faster execution and portability.
Name three TensorFlow callbacks and their uses.
EarlyStopping: stops training when a metric stops improving. ModelCheckpoint: saves model at intervals. ReduceLROnPlateau: reduces learning rate when a metric plateaus.
What is TensorBoard used for?
A visualization tool for tracking metrics, model graphs, profiling, and hyperparameter tuning.
Describe Mixup and CutMix data augmentation techniques.
Mixup: creates new samples by weighted linear combination of two images and their labels. CutMix: cuts a patch from one image and pastes it onto another, adjusting labels proportionally.
What is Weights & Biases (W&B) used for?
An MLOps platform for experiment tracking, hyperparameter sweeps, dataset/model versioning, and collaboration.
What are TensorFlow Records?
An efficient binary format for storing and serializing data, enabling faster training pipelines.
How can you create a custom loss function in TensorFlow?
Define a function that takes true labels and predictions and returns a scalar loss, or subclass
tf.keras.losses.Loss.What is overfitting and what are three ways to mitigate it?
Overfitting: model performs well on training data but poorly on unseen data. Mitigations: data augmentation, dropout, regularization (L1/L2), early stopping, reduce network complexity.
What is the role of dropout in a neural network?
Randomly drops a fraction of neurons during training to prevent co-adaptation and improve generalization.
How does L1/L2 regularization work?
Adds a penalty term to the loss function proportional to the absolute (L1) or squared (L2) weights, discouraging large weights.
What is the output activation function for multi-class classification and why?
Softmax, which converts logits into a probability distribution that sums to 1.
What loss function is used for multi-class classification in TensorFlow?
CategoricalCrossentropy(for one-hot labels) orSparseCategoricalCrossentropy(for integer labels).What is Top-K accuracy?
A metric that considers a prediction correct if the true class is within the top K highest probabilities (e.g., Top-2).
What is the key idea behind VGGNet?
Stacking multiple small 3x3 filters is more effective and computationally cheaper than using larger filters.
What innovation did ResNet introduce?
Residual blocks with skip connections to mitigate the vanishing gradient problem, enabling very deep networks (e.g., ResNet-50, ResNet-152).
How does MobileNet reduce computational cost?
By using depthwise separable convolutions, which factorize a standard convolution into depthwise and pointwise convolutions.
What is compound scaling in EfficientNet?
Uniformly scaling network depth, width, and input resolution using a compound coefficient.
What is transfer learning and how is it implemented?
Using a pre-trained model (e.g., EfficientNet) as a feature extractor by replacing its final classification layers with new ones for the target task.
How can you visualize what a CNN learns?
By creating a new model that outputs intermediate layer feature maps; early layers detect edges/colors, deeper layers detect high-level concepts.
What is Grad-CAM and how does it work?
A technique to produce a heatmap highlighting influential regions for a prediction by computing gradients of the target class score w.r.t. the final convolutional feature maps.
How do Vision Transformers (ViTs) process an image?
Split image into fixed-size patches, flatten and linearly project into patch embeddings, add class and positional embeddings, then pass through a Transformer encoder.
What is ONNX and its advantage?
Open Neural Network Exchange format allows models to be converted between frameworks (e.g., TensorFlow to PyTorch) and run with ONNX Runtime on various hardware.
What is model quantization and what types exist?
Quantization reduces model size and speeds up inference by converting weights from 32-bit floats to lower-bit formats (e.g., 8-bit integers). Types: post-training dynamic, post-training static, and Quantization-Aware Training (QAT).
What is TensorFlow Lite used for?
Deploying models on mobile and edge devices; the TensorFlow Lite converter can quantize models.
How can you serve a model as a REST API?
Use FastAPI to create endpoints that load the model and make predictions, with automatic OpenAPI and Swagger UI documentation.
What is YOLO and how does it formulate object detection?
YOLO (You Only Look Once) treats object detection as a regression problem, dividing the image into a grid (e.g., 7x7). Each cell predicts B bounding boxes, confidence scores, and class probabilities. Output tensor shape: S×S×(B×5+C).
How are bounding box coordinates encoded in YOLO?
The center (x, y) is predicted relative to the grid cell; width and height are predicted relative to the whole image.
What components make up the YOLO loss function?
Coordinate loss (box center and size), objectness loss (for cells with an object), no-objectness loss (cells without), and classification loss.
What is Intersection over Union (IoU) used for in YOLO?
To determine which predicted box is 'responsible' for an object by measuring overlap with the ground truth box.
What is Non-Max Suppression (NMS) in object detection?
A post-processing step that eliminates duplicate detections by discarding boxes with high IoU overlap with a higher-confidence box.
How does a Variational Autoencoder (VAE) differ from a standard autoencoder?
VAE outputs a mean and variance for a latent distribution instead of a discrete latent vector; uses the reparameterization trick (z=μ+σ⋅ϵ) for backpropagation.
What are the two components of a GAN and their roles?
Generator (G) creates fake data; Discriminator (D) distinguishes real from fake. Training is a min-max game.
List three tips for stable GAN training.
Label smoothing (use soft labels like 0.9/0.1), flip generator labels from 0 to 1 for better gradients, use Adam optimizer, use leaky ReLU activations.

Ask anything
We've read this whole study set, so questions about it get the best answers.