Practice
import torch
Q = torch.rand(2, 3, 4)
K = torch.rand(2, 4, 4)
V = torch.rand(2, 4, 5)
output = torch.matmul(torch.matmul(Q, K.transpose(-2, -1)), V)Solution
Step 1: Analyze matrix multiplications
The first multiplicationtorch.matmul(Q, K.transpose(-2, -1))results in a shape of (2, 3, 4). The second multiplication with V results in (2, 3, 5).Step 2: Eliminate wrong options
(2, 4, 5) is incorrect because it assumes incorrect dimensions for Q. (2, 3, 4) is incorrect because it doesn't account for the final multiplication with V. (2, 5, 5) is incorrect because it assumes incorrect dimensions for the final output.Final Answer:
Option D -> Option DQuick Check:
Check matrix dimensions after each multiplication. [OK]
Solution
Step 1: Consider the effect of outliers on scaling methods.
Normalization is sensitive to outliers as it scales data to a fixed range.Step 2: Choose the method less affected by outliers.
Standardization is less affected because it centers data around the mean and scales by standard deviation.Final Answer:
Option D -> Option DQuick Check:
Standardize for outliers, less sensitive. [OK]
Solution
Step 1: Consider resource constraints
Mobile devices require models that are both fast and lightweight.Step 2: Match model to constraints
Tiny YOLO is designed for environments with limited resources, balancing speed and size.Final Answer:
Option A -> Option AQuick Check:
Mobile = Tiny YOLO [OK]
Solution
Step 1: Consider scalability and speed
Approximate methods like locality-sensitive hashing are suitable for large-scale, real-time systems.Step 2: Eliminate wrong options
Use exact KNN with a large number of neighbors. is incorrect due to inefficiency. Reduce the number of features to improve speed. is wrong as feature reduction alone may not suffice. Use a single global model for all users. is incorrect because personalization is key in recommendations.Final Answer:
Option A -> Option AQuick Check:
Approximate methods for real-time scale. [OK]
Solution
Step 1: Consider the nature of image data
Image data often requires handling non-linear separability due to complex patterns.Step 2: Evaluate kernel suitability
Linear kernel, because it is computationally efficient for image data is incorrect because linear kernels are not suitable for non-linear data. Polynomial kernel, because it captures complex patterns in image data is incorrect because polynomial kernels can be computationally expensive. Sigmoid kernel, because it mimics neural network behavior is incorrect because sigmoid kernels are less commonly used and can be unstable.Final Answer:
Option A -> Option AQuick Check:
RBF kernel for non-linear image data [OK]
