PROFESSIONAL-MACHINE-LEARNING-ENGINEER practice question 26 of 35
You are training a Resnet model on Al Platform using TPUs to visually categorize types of defects in automobile engines. You capture the training profile using the Cloud TPU profiler plugin and observe that it is highly input-bound. You want to reduce the bottleneck and speed up your model training process. Which modifications should you make to the tf .data dataset? Choose 2 answers
Full set: 283 questionsThe training process is described as "highly input-bound," which means the accelerator (TPU) is frequently idle while waiting for the data input pipeline to deliver the next batch. The goal is to optimize the tf.data pipeline to ensure data is ready for the TPU as soon as it finishes the previous step.
1. interleave: This transformation reads from multiple input files concurrently. For large datasets stored in multiple files (e.g., on Google Cloud Storage), this parallelizes the I/O-heavy data extraction step, significantly improving read throughput and reducing the time spent waiting for data.
2. prefetch: This transformation decouples data preprocessing from model execution. It creates a software pipeline where the CPU prepares one or more future batches of data in the background while the TPU is busy training on the current batch. This overlap ensures the TPU rarely has to wait for data, directly mitigating the input bottleneck.
B. Reducing the repeat parameter shortens the total number of training epochs but does not improve the training speed or fix the per-step bottleneck.
C. Increasing the shuffle buffer size improves the quality of data randomization but does not inherently increase data throughput or resolve an input bottleneck.
E. Decreasing the batch size generally leads to lower hardware utilization on accelerators like TPUs and can slow down overall training, exacerbating the problem.
1. TensorFlow Core Documentation, "Better performance with the tf.data API":
For option A (interleave): In the "Parallelizing data extraction" section, the documentation states, "To mitigate the effect of I/O latency, you can interleave the reading of multiple files using tf.data.Dataset.interleave." This directly supports using interleave to address I/O bottlenecks.
For option D (prefetch): In the "Prefetching" section, it explains, "This allows the data preprocessing and model execution to overlap... tf.data.Dataset.prefetch decouples the time when data is produced from the time when data is consumed. In particular, it can be used to overlap the preprocessing of a training example with the model execution of a training step."
2. Google Cloud Documentation, "Performance guide for TPUs using TensorFlow 2.x":
For options A and D: In the "Input pipeline optimization" section, the guide explicitly recommends best practices for input-bound workloads: "Use dataset.interleave() to read from multiple files at once" and "Use dataset.prefetch() to overlap the host-side preprocessing work with the device-side training work." This confirms these are standard, sanctioned solutions for TPU performance issues.
3. Google Cloud Documentation, "Cloud TPU tools: Profiler":
The "Common issues revealed by the profiler" section describes the "Your program is highly input-bound" scenario. The recommended actions include "Use tf.data.Dataset.prefetch" and other tf.data optimizations, validating that prefetching is a primary solution for the problem identified by the profiler.
Keep practicing
Take the free PROFESSIONAL-MACHINE-LEARNING-ENGINEER practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other PROFESSIONAL-MACHINE-LEARNING-ENGINEER practice questions
- Question 1You work for an advertising company and want to understand the effectiveness of your comp…
- Question 2You developed a custom model by using Vertex Al to forecast the sales of your company s p…
- Question 3You are an ML engineer at a global shoe store. You manage the ML models for the company's…
- Question 5During batch training of a neural network, you notice that there is an oscillation in the…
- Question 6You want to rebuild your ML pipeline for structured data on Google Cloud. You are using P…
- Question 7Your team is building a convolutional neural network (CNN)-based architecture from scratc…
