Google Professional Machine Learning Engineer Question 200
Select 3Google Cloud PlatformYou are working on a deep learning project and need to monitor model training metrics such as loss and accuracy in real-time. The project uses TensorFlow and PyTorch for training different models. How can you use TensorBoard to effectively track training metrics for both frameworks?
- A
Use TensorFlow's
tf.summaryAPI to log metrics and launch TensorBoard to visualize them. - B
Use PyTorch's
torch.utils.tensorboard.SummaryWriterto log metrics and launch TensorBoard to visualize them. - C
Convert PyTorch models to TensorFlow models using ONNX and then log metrics with TensorFlow's
tf.summaryAPI. - D
Ensure the logs from both TensorFlow and PyTorch are written to separate directories to avoid conflicts in TensorBoard visualizations.
- E
Use TensorFlow's
tf.keras.callbacks.TensorBoardcallback to monitor both TensorFlow and PyTorch models without additional configuration.
Show answer and explanation
Correct answers: A, B, D
Explanation
TensorBoard is a powerful tool for monitoring training metrics in real-time. Both TensorFlow and PyTorch have native support for TensorBoard integration through their respective logging APIs (tf.summary for TensorFlow and torch.utils.tensorboard.SummaryWriter for PyTorch). When working with both frameworks in the same project, it is critical to separate the log directories to avoid conflicts in visualizations. No additional model conversion or configuration is needed for this integration.
- A. Correct.
Correct: TensorFlow provides the
tf.summaryAPI to log metrics, which can then be visualized in TensorBoard. This is the standard approach for TensorFlow models. - B. Correct.
Correct: PyTorch uses the
torch.utils.tensorboard.SummaryWriterto log metrics, which are compatible with TensorBoard. This is the standard approach for PyTorch models. - C. Incorrect.
Incorrect: While ONNX can be used for model conversion between frameworks, it is not necessary for logging training metrics. Both TensorFlow and PyTorch have their own mechanisms that integrate directly with TensorBoard.
- D. Correct.
Correct: Writing logs to separate directories for TensorFlow and PyTorch ensures there are no conflicts in the visualization, as TensorBoard reads logs from specified directories.
- E. Incorrect.
Incorrect: The
tf.keras.callbacks.TensorBoardcallback is specific to TensorFlow's Keras API and does not support PyTorch models directly.