How to Properly Combine TensorFlow’s Dataset API and Keras?

Update June 09, 2018 Starting from Tensorflow 1.9, one can pass tf.data.Dataset object directly into keras.Model.fit() and it would act similar to fit_generator. A complete example can be found on this gist. # Load mnist training data (x_train, y_train), _ = tf.keras.datasets.mnist.load_data() training_set = tfdata_generator(x_train, y_train,is_training=True) model = # your keras model here model.fit( training_set.make_one_shot_iterator(), … Read more

Meaning of buffer_size in Dataset.map , Dataset.prefetch and Dataset.shuffle

TL;DR Despite their similar names, these arguments have quite difference meanings. The buffer_size in Dataset.shuffle() can affect the randomness of your dataset, and hence the order in which elements are produced. The buffer_size in Dataset.prefetch() only affects the time it takes to produce the next element. The buffer_size argument in tf.data.Dataset.prefetch() and the output_buffer_size argument … Read more

How to import an saved Tensorflow model train using tf.estimator and predict on input data

I tried to search for a good base example, but it appears the documentation and samples are a bit scattered for this topic. So let’s start with a base example: the tf.estimator quickstart. That particular example doesn’t actually export a model, so let’s do that (not need for use case 1): def serving_input_receiver_fn(): “””Build the … Read more

Which TensorFlow and CUDA version combinations are compatible?

TL;DR) See this table: https://www.tensorflow.org/install/source#gpu Generally: Check the CUDA version: cat /usr/local/cuda/version.txt and cuDNN version: grep CUDNN_MAJOR -A 2 /usr/local/cuda/include/cudnn.h and install a combination as given below in the images or here. The following images and the link provide an overview of the officially supported/tested combinations of CUDA and TensorFlow on Linux, macOS and Windows: … Read more

On Windows, running “import tensorflow” generates No module named “_pywrap_tensorflow” error

The problem was the cuDNN Library for me – for whatever reason cudnn-8.0-windows10-x64-v6.0 was NOT working – I used cudnn-8.0-windows10-x64-v5.1 – ALL GOOD! My setup working with Win10 64 and the Nvidia GTX780M: Be sure you have the lib MSVCP140.DLL by checking your system/path – if not get it here Run the windows installer for … Read more