New features in tf.data
tf.data.service
Modern accelerators (GPUs, TPUs) are incredibly fast. To avoid performance bottlenecks, it’s important to ensure that your data loading and preprocessing pipeline is fast enough to provide data to the accelerator when it’s needed. For example, imagine your GPU can classify 200 examples/second, but your data input pipeline can only load 100 examples/second from disk. In this case, your GPU would be idle (waiting for data) 50% of the time. And, that’s assuming your input-pipeline is already overlapped with GPU computation (if not, your GPU would be waiting for data 66% of the time).In this scenario, you can double training speed by using the , and you can find a complete example .
Once you have a tf.data.service running, you can add distributed dataset processing to your existing tf.data pipelines using the as well. Be sure to check out the transformations - which can greatly speed up your pipeline in a single line of code.
tf.data snapshot
The to learn more.New features in the TF Profiler
The in TF 2.2) makes it easier to spot performance bottlenecks. It can help you identify when an application is input-bound, and can provide suggestions for what can be done to fix it. You can learn more about this workflow in the or in sampling mode through the TensorBoard “capture profile” UI (you can find more information about these modes in this and to create a tf.data.Dataset that yields batches of images from the subdirectories and labels:train_ds = tf.keras.preprocessing.image_dataset_from_directory(
“datasets/cats_and_dogs”,
validation_split=0.2,
subset="training",
seed=0,
image_size=(img_height, img_width),
batch_size=32)train_ds = train_ds.cache().prefetch(buffer_size=tf.data.experimental.AUTOTUNE).cache(filename) to automatically create an efficient on-disk cache, which is faster to read than many small files. You learn more in the preprocessing layer, for example, you can develop a text classification model that accepts raw strings as input (without having to re-implement any of the logic for tokenization, standardization, vectorization, or padding server-side).
Note that all of these layers can either be included inside your model, or can be applied to your tf.data input-pipeline via the map transformation. You can find an example on GitHub to let us know how we can better support your use case.
SOCIAL SHARE CARD GENERATOR