Skip to Content
Hands-On Convolutional Neural Networks with TensorFlow
book

Hands-On Convolutional Neural Networks with TensorFlow

by Iffat Zafar, Giounona Tzanidou, Richard Burton, Nimesh Patel, Leonardo Araujo
August 2018
Intermediate to advanced
272 pages
7h 2m
English
Packt Publishing
Content preview from Hands-On Convolutional Neural Networks with TensorFlow

Prefetching

Another way we can make an efficient data pipeline is by always having a batch of data ready to send to the GPU. Ideally, when training our model, we would like our GPU usage to be at 100% all the time. This way, we are making the maximum usage of our expensive piece of hardware that is efficiently computing forward and backward passes while training.

For this to happen though, we need our CPUs to load and prepare a batch of images, ready to pass to the GPU, during the time it takes to do a forward and backward pass of the model. Luckily, we can do this easily using a simple prefetch transformation after we collect our batch, as follows:

train_dataset= train_dataset.batch(128).prefetch(1) 

Using prefetch will make sure our data ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Computer Vision Using Deep Learning: Neural Network Architectures with Python and Keras

Computer Vision Using Deep Learning: Neural Network Architectures with Python and Keras

Vaibhav Verdhan

Publisher Resources

ISBN: 9781789130331Supplemental Content