Search code examples
pythontensorflowdeprecatedattributeerror

How is random_batch deprecated in Tensorflow?


I was doing this tutorial and I got stuck at the line with data.random_batch(batch_size=train_batch_size). It's looking like there's been some deprecation in tensorflow. I am getting the following error:

AttributeError: 'Datasets' object has no attribute 'random_batch'

I've been googling for a solution, but no luck. Does anyone know where this method hides now?


Solution

  • You can use tf.data.dataset.batch(batch_size = train_batch_size) for batching the input data but for that frist you have to create a dataset from your input data by using the relevant method for your data for example dataset = tf.data.TFRecordDataset(filename). After that you can create an iterator to get each batch for training by defining an iterator dataset.make_one_shot_iterator(). A detailed explanation could be find on the tensorflow guide here