Google Professional Machine Learning Engineer Question 201
Select 4Google Cloud PlatformYou are training a deep learning model using TensorFlow on Google Cloud AI Platform and want to use TensorBoard for visualizing metrics like loss and accuracy. Later, you plan to train a similar model in PyTorch and still want to use TensorBoard for consistency in monitoring. Which of the following steps should you take to ensure TensorBoard works seamlessly with both frameworks?
- A
Log TensorFlow-specific metrics using
tf.summaryduring training. - B
Install the
torch.utils.tensorboardmodule for PyTorch integration. - C
Launch TensorBoard pointing to a shared log directory for both frameworks.
- D
Use the TensorFlow Profiler plugin, as it is compatible with PyTorch out of the box.
- E
Ensure that the log directory is cleared before starting a new training run for either framework.
Show answer and explanation
Correct answers: A, B, C, E
Explanation
TensorBoard is a versatile tool for visualizing training metrics and can be used with multiple frameworks like TensorFlow and PyTorch. To ensure seamless integration, you need to use framework-specific logging utilities (tf.summary for TensorFlow and torch.utils.tensorboard for PyTorch) and set up a shared log directory for TensorBoard to read from. Clearing the log directory before starting new runs avoids conflicts or outdated data being displayed.
- A. Correct.
Correct: TensorFlow uses
tf.summaryfor logging metrics that TensorBoard can visualize. This step is essential for integrating TensorBoard with TensorFlow. - B. Correct.
Correct: PyTorch requires the
torch.utils.tensorboardmodule to log metrics in a TensorBoard-compatible format. Without this, TensorBoard cannot interpret PyTorch logs. - C. Correct.
Correct: A shared log directory allows TensorBoard to aggregate and display metrics from both TensorFlow and PyTorch models, which is ideal for consistent monitoring.
- D. Incorrect.
Incorrect: The TensorFlow Profiler plugin is not compatible with PyTorch out of the box. PyTorch has its own utilities for TensorBoard integration, such as
torch.utils.tensorboard. - E. Correct.
Correct: Clearing the log directory before each training run prevents mixing metrics from previous runs, ensuring accurate visualization in TensorBoard.