Google Professional Machine Learning Engineer Question 369
Single answerGoogle Cloud PlatformYou are building a machine learning pipeline on Google Cloud. During training, you preprocess raw data by normalizing numerical features and encoding categorical features using TensorFlow Transform (TFX). To ensure consistent data preprocessing during both training and serving, what should you do?
- A
Export the preprocessing logic as a SavedModel using TFX and apply it during serving.
- B
Manually rewrite the preprocessing code in the serving application to match the training pipeline.
- C
Precompute the preprocessed data during training and serve the preprocessed data directly.
- D
Use a custom preprocessing library to ensure consistency between training and serving.
Show answer and explanation
Correct answer: A
Explanation
Ensuring consistent data preprocessing between training and serving is critical to avoid data skew and ensure reliable model performance. By using TFX to export preprocessing logic as a SavedModel, you can apply the exact same transformations during both training and serving, avoiding the need for manual replication or external libraries.
- A. Correct.
This is correct. TFX allows you to export preprocessing logic as a SavedModel, ensuring the same logic is applied during both training and serving.
- B. Incorrect.
This is incorrect. Manually rewriting the preprocessing logic increases the risk of inconsistencies and errors between training and serving.
- C. Incorrect.
This is incorrect. Precomputing preprocessed data is not scalable for real-time inference scenarios and does not ensure flexibility for new data.
- D. Incorrect.
This is incorrect. A custom preprocessing library might reduce inconsistencies but does not guarantee compatibility with TensorFlow pipelines in training and serving.