Google Professional Machine Learning Engineer Question 202
Select 4Google Cloud PlatformYou are training a machine learning model using TensorFlow and PyTorch frameworks and want to visualize metrics such as loss, accuracy, and gradients in a single dashboard. You decide to use TensorBoard for this purpose. Which of the following steps are required to correctly set up TensorBoard for monitoring your training process with both frameworks?
- A
Use TensorFlow’s
tf.summaryAPI to log scalar values like loss and accuracy during training. - B
Install the PyTorch TensorBoard plugin and use
SummaryWriterto write logs for PyTorch models. - C
Start the TensorBoard server by running the command
tensorboard --logdir=logs/. - D
Manually convert TensorFlow logs to PyTorch-compatible format using a custom script.
- E
Configure separate log directories for TensorFlow and PyTorch models to avoid conflicts.
Show answer and explanation
Correct answers: A, B, C, E
Explanation
To use TensorBoard for monitoring models trained using TensorFlow and PyTorch, you need to use the respective logging APIs (tf.summary for TensorFlow and SummaryWriter for PyTorch) to generate logs. These logs should be stored in separate directories to avoid conflicts. Then, you can start the TensorBoard server using the --logdir option to visualize the metrics. No manual conversion of logs is necessary as TensorBoard natively supports both TensorFlow and PyTorch formats.
- A. Correct.
Correct. TensorFlow provides the
tf.summaryAPI to log scalar values, histograms, and other metrics during model training. This is a necessary step to visualize TensorFlow training metrics in TensorBoard. - B. Correct.
Correct. In PyTorch, you can use the
torch.utils.tensorboard.SummaryWriterto log metrics and other information that TensorBoard can consume. - C. Correct.
Correct. Starting the TensorBoard server with the appropriate
--logdircommand is required to visualize the logs generated by TensorFlow and PyTorch. - D. Incorrect.
Incorrect. TensorFlow and PyTorch logs are already compatible with TensorBoard. No manual conversion is necessary.
- E. Correct.
Correct. Using separate log directories for TensorFlow and PyTorch ensures that logs from both frameworks do not overwrite or conflict with each other.