nerdexam
Google

PROFESSIONAL-MACHINE-LEARNING-ENGINEER · Question #146

You work for the AI team of an automobile company, and you are developing a visual defect detection model using TensorFlow and Keras. To improve your model performance, you want to incorporate some…

The correct answer is A. Embed the augmentation functions dynamically in the tf.Data pipeline. To optimize image augmentation for runtime and compute resources, embedding augmentation functions directly within the tf.data pipeline allows for dynamic, on-the-fly processing that efficiently uses available resources.

Submitted by ngozi_ng· Apr 18, 2026Data processing and feature engineering

Question

You work for the AI team of an automobile company, and you are developing a visual defect detection model using TensorFlow and Keras. To improve your model performance, you want to incorporate some image augmentation functions such as translation, cropping, and contrast tweaking. You randomly apply these functions to each training batch. You want to optimize your data processing pipeline for run time and compute resources utilization. What should you do?

Options

  • AEmbed the augmentation functions dynamically in the tf.Data pipeline.
  • BEmbed the augmentation functions dynamically as part of Keras generators.
  • CUse Dataflow to create all possible augmentations, and store them as TFRecords.
  • DUse Dataflow to create the augmentations dynamically per training run, and stage them as

How the community answered

(50 responses)
  • A
    84% (42)
  • B
    10% (5)
  • C
    2% (1)
  • D
    4% (2)

Why each option

To optimize image augmentation for runtime and compute resources, embedding augmentation functions directly within the `tf.data` pipeline allows for dynamic, on-the-fly processing that efficiently uses available resources.

AEmbed the augmentation functions dynamically in the tf.Data pipeline.Correct

Embedding augmentation functions directly in the `tf.data` pipeline allows for dynamic, on-the-fly augmentation of images during training, which is highly efficient for resource utilization. `tf.data` can parallelize and prefetch these operations, ensuring the GPU is fed data continuously without bottlenecks, and avoiding the need to store augmented data.

BEmbed the augmentation functions dynamically as part of Keras generators.

While Keras generators can perform augmentations, `tf.data` pipelines offer superior performance optimizations like parallelization, prefetching, and buffering that are harder to achieve with basic Keras generators, potentially leading to I/O bottlenecks.

CUse Dataflow to create all possible augmentations, and store them as TFRecords.

Creating and storing all possible augmentations in advance would lead to an explosion of data, requiring immense storage and processing power, which is highly inefficient and not scalable for dynamic, random augmentations.

DUse Dataflow to create the augmentations dynamically per training run, and stage them as

Using Dataflow to create augmentations dynamically per training run would introduce significant latency and cost overhead for real-time augmentation during training, as Dataflow is typically used for large-scale batch or stream processing.

Concept tested: Efficient image augmentation with tf.data

Source: https://www.tensorflow.org/guide/data_performance

Topics

#Image Augmentation#tf.data pipeline#Performance Optimization#Data Preprocessing

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-MACHINE-LEARNING-ENGINEER Practice