You train a CNN to distinguish cat photos from dog photos, but the source images arrive at many different heights and widths. Which preprocessing step is required so every sample matches the network’s fixed input shape?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Here's where it gets interesting for you. CNNs in the classic fixed-input setup expect every batch tensor to share the same height, width, and channels—like every suitcase fitting the same airline bin. If one photo is 4000×3000 and another is 64×64, something has to give: resize or crop-and-resize to the architecture's size (224×224, 256×256, whatever you chose). Random rotation? Great for augmentation, wrong answer for shape consistency. Grayscale? Changes channels, not the H×W problem. Blind padding without a target size just leaves you with mismatched tensors. Exam trap is confusing 'any preprocessing' with 'the step that enforces dimensions.' Land this: variable resolution in, fixed spatial size out, then normalize and train. Nice and clean.
Full explanation below image
Full Explanation
Most convolutional classifiers are designed around a predetermined input tensor shape such as N×C×H×W. Fully connected heads, some normalization layers, and batching logic assume every sample shares the same height H and width W. Real photo collections violate that assumption: phone cameras, web scrapes, and datasets like pet images include wildly different resolutions and aspect ratios. Therefore, a mandatory preprocessing step is to map each image to the network’s required spatial size—commonly via resize, center crop, random resized crop (during training), or letterbox-style resize-with-padding that preserves aspect ratio while producing a fixed canvas. Skipping this step typically causes runtime shape errors or silent misalignment when tensors cannot stack into a batch.
Random rotation improves robustness to orientation and is a valuable augmentation, yet rotating a 300×200 image still yields roughly 300×200 geometry; it does not solve batch shape mismatches. Grayscale conversion reduces channels from three to one and may discard useful color cues for cats and dogs; it is independent of fixing H and W. Padding or filling can be part of a correct pipeline when you pad to a known target size, but the option that merely mentions filling without establishing the model’s fixed dimensions is incomplete and misleading.
Best practice: decide the input resolution based on the backbone and compute budget; apply a deterministic validation resize/crop; use stochastic resized crops and light augmentations at train time; then normalize with dataset or pretrained-model statistics. Framework loaders (for example torchvision transforms) encode this order explicitly. On exams, when the stem stresses mixed resolutions and CNN consistency, the answer is resize to a fixed dimension—not augmentation-only or color-only transforms. That single step is what makes batched tensor training possible and keeps train-time and inference-time geometry aligned with the architecture you chose.