Google Professional Machine Learning Engineer Question 513
Single answerGoogle Cloud PlatformYou are building a machine learning pipeline on Google Cloud to classify images of animals into multiple categories. The input data consists of images of varying sizes and resolutions. To preprocess the data, you need to ensure that the input tensors for the model have consistent dimensions. Which approach should you use to address this issue?
- A
Resize all images to a fixed height and width before feeding them into the model
- B
Use padding to make all images the same size without distorting the aspect ratio
- C
Store the original image dimensions as metadata and let the model handle resizing dynamically
- D
Use a pre-trained model that supports variable input dimensions without preprocessing
Show answer and explanation
Correct answer: A
Explanation
Most machine learning models require input tensors to have consistent dimensions. Resizing all images to a fixed height and width is a standard preprocessing step to ensure uniformity in input data. Other approaches, such as padding or relying on the model to handle resizing dynamically, are either less common or not directly supported by standard architectures.
- A. Correct.
Correct. Resizing all images to a fixed height and width ensures that the input tensors have consistent dimensions, which is required for most machine learning models.
- B. Incorrect.
Incorrect. Padding can preserve the aspect ratio but still results in inconsistent dimensions if the original images have widely varying sizes.
- C. Incorrect.
Incorrect. Storing dimensions as metadata does not address the issue of tensor consistency required by the model. The model cannot dynamically handle resizing without explicit preprocessing.
- D. Incorrect.
Incorrect. While some advanced models, like certain vision transformers, support variable input dimensions, this is not the standard approach and depends on specific architectures.