0
0
TensorFlowml~10 mins

Prefetching for performance in TensorFlow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add prefetching to the dataset for better performance.

TensorFlow
dataset = dataset.shuffle(1000).batch(32).[1](tf.data.AUTOTUNE)
Drag options to blanks, or click blank then click option'
Aprefetch
Bcache
Crepeat
Dmap
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cache' instead of 'prefetch' which caches data but doesn't overlap data preparation.
Using 'repeat' which repeats the dataset but doesn't improve performance by preloading.
2fill in blank
medium

Complete the code to prefetch data with an automatic buffer size.

TensorFlow
dataset = dataset.batch(64).[1](buffer_size=tf.data.AUTOTUNE)
Drag options to blanks, or click blank then click option'
Ashuffle
Bcache
Cprefetch
Drepeat
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cache' which stores data but does not overlap data loading.
Using 'shuffle' which randomizes data order but does not prefetch.
3fill in blank
hard

Fix the error in the code to correctly prefetch the dataset.

TensorFlow
dataset = dataset.batch(32).prefetch([1])
Drag options to blanks, or click blank then click option'
ANone
B32
CTrue
Dtf.data.AUTOTUNE
Attempts:
3 left
💡 Hint
Common Mistakes
Passing an integer like 32 which may not optimize performance.
Passing None or True which are invalid for prefetch buffer size.
4fill in blank
hard

Fill both blanks to create a dataset pipeline that shuffles, batches, and prefetches data.

TensorFlow
dataset = dataset.[1](1000).[2](64).prefetch(tf.data.AUTOTUNE)
Drag options to blanks, or click blank then click option'
Ashuffle
Bbatch
Crepeat
Dcache
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'repeat' instead of 'shuffle' which repeats data but does not randomize.
Using 'cache' instead of 'batch' which caches data but does not group it.
5fill in blank
hard

Fill all three blanks to build a TensorFlow dataset pipeline that caches, shuffles, batches, and prefetches data.

TensorFlow
dataset = dataset.[1]().[2](500).[3](32).prefetch(tf.data.AUTOTUNE)
Drag options to blanks, or click blank then click option'
Acache
Bshuffle
Cbatch
Drepeat
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'repeat' instead of 'cache' which repeats data but does not store it.
Swapping the order of shuffle and batch which affects randomness.