Difficulty: Medium Tags: Computer Vision, Transformers, Tensor Shapes
A vision transformer converts an image into non-overlapping square patches. A data loader silently drops border pixels when the image dimensions are not divisible by the patch size. This task rejects such images rather than silently dropping pixels.
For image height H, width W, patch size P, and embedding dimension D,
patches are valid only if H mod P == 0 and W mod P == 0. If valid, the
patch count is:
N = (H / P) * (W / P)
and the patch-projection weight matrix has P^2 * C * D parameters for C
input channels, excluding bias.
H, W, P, C, D.
If the dimensions are not divisible by P, return None. Otherwise return
(N, params).
1 <= H, W <= 10^5, 1 <= P, C, D <= 10^4.Input
H = 224, W = 224, P = 16, C = 3, D = 768
Output
(196, 589824)
Explanation: The image has 14 x 14 = 196 patches. Projection weights
contain 16^2 * 3 * 768 = 589824 parameters.
No results yet
Run your code to check it against the examples, or submit to run every test.