tf.data: Fast, flexible, and easy-to-use input pipelines (TensorFlow Dev Summit 2018)

TensorFlow · 68K views · 2018 · 15:10

Open on YouTube

Machine learning & deep learningSoftware performance & optimizationtalkdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering or asking about tf.data pipelines, input performance, and using Datasets with eager execution.

Recommended by 2 people across 2 different months, 2018 to 2018.

What it is

A 15-minute talk from the TensorFlow Dev Summit 2018 in which Derek Murray introduces tf.data, TensorFlow's recommended API for building input pipelines. He covers recent improvements in performance, flexibility and ease of use, including how tf.data combines with eager execution.

What people said

Recommends DomJack · 2018-04 · Stack Overflow · on “Tensorflow CNN image augmentation pipeline”

There's a really good article [LINK] and talk [this video] released recently that go over the API in a lot more detail than my response here. Here's a brief example: import tensorflow as tf import numpy as np def read_data(): n_train = 100 n_test = 50 height = 20 width = 30 channels = 3 trainX = (np.random.random( size=(n_train, height, width, channels)) * 255).astype(np.uint8) testX = (np.random.random( size=(n_test, height, width, channels))*255).astype(np.uint8) trainY = (np.random.random(size=(n_train,))*10).astype(np.int32) testY = (np.random.random(size=(n_test,))*10).astype(np.int32) return trainX, testX, trainY, testY trainX, testX, trainY, testY = read_data() # trainX [num_image, height,

Recommends McAngus · 2018-12 · Stack Overflow · on “AWS, Cuda, Tensorflow”

The performance of any machine learning model depends on many things. Including but not limited to: How much pre-processing you do, how much data you copy from CPU to GPU, Op bottlenecks, and many more. Check out the tensorflow performance guide [LINK] as a first step. There are also a few videos from the tensorflow dev summit 2018 that talk about performance. How to properly use tf.data [this video] , and how to debug performance [LINK] are two that I recommend. The only thing I can say for sure is that JSON is a bad format for this purpose. You should switch to tfrecord format [LINK] , which uses protobuf ( better than JSON [LINK] ). Unfortunately performance and optimisation of any system take

Cites Kilian Obermeier · 2018-04 · Stack Overflow · on “How can I use tf.data Datasets in eager execution mode?”

In the tf.data talk [this video] at the TensorFlow Dev Summit 2018, Derek Murray presented a way to combine the tf.data [LINK] API with TensorFlow's eager execution mode (at 10:54). I tried out a simplified version of the code shown there: import tensorflow as tf tf.enable_eager_execution() dataset = tf.data.Dataset.from_tensor_slices(tf.random_uniform([50, 10])) dataset = dataset.batch(5) for batch in dataset: print(batch) causing TypeError: 'BatchDataset' object is not iterable I also tried using dataset.make_one_shot_iterator() and dataset.make_initializable_iterator() to iterate over the dataset, but they result in RuntimeError: dataset.make_one_shot_iterator is not supported when eager execu

Cites GunnarTrollson · 2018-08 · Stack Overflow · on “How to read (decode) tfrecords with tf.data API”

I have a custom dataset, that I then stored as tfrecord, doing # toy example data label = np.asarray([[1,2,3], [4,5,6]]).reshape(2, 3, -1) sample = np.stack((label + 200).reshape(2, 3, -1)) def bytes_feature(values): """Returns a TF-Feature of bytes. Args: values: A string. Returns: A TF-Feature. """ return tf.train.Feature(bytes_list=tf.train.BytesList(value=[values])) def labeled_image_to_tfexample(sample_binary_string, label_binary_string): return tf.train.Example(features=tf.train.Features(feature={ 'sample/image': bytes_feature(sample_binary_string), 'sample/label': bytes_feature(label_binary_string) })) def _write_to_tf_record(): with tf.Graph().as_default(): image_placeholder = tf.pla

Cites Salvador Dali · 2018-11 · Stack Overflow · on “How to improve the performance of this data pipeline for my tensorflow model”

I have a tensorflow model which I am training on google-colab [LINK] . The actual model is more complex, but I condensed it into a reproducible example [LINK] (removed saving/restoring, learning rate decay, asserts, tensorboard events, gradient clipping and so on). The model works reasonably (converges to acceptable loss) and I am looking for a way to speed up the training (iterations per second). Currently on colab's GPU it takes 10 minutes to train for 1000 iteration . With my current batch size of 512 it means that the model processes ~850 examples per second (I would prefer to have a batch size of 512 unless other sizes provide reasonable speedup. By itself changing batch size does not c