question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Iterating dataset as numpy with batch_size > 1 failed to work.

See original GitHub issue

Short description When I loaded a dataset (cifar10) with batch_size set to larger than 1, converted it to a generator with tfds.as_numpy and tried to iterate over the generator, I got the following repeated warning and no data:

2019-03-26 10:09:57.170947: W tensorflow/core/framework/model.cc:419] Failed to find a tunable parameter that would decrease the output time, aborting the current optimization attempt.

Environment information

  • Operating System: Mac OSX
  • Python version: 2.7
  • tensorflow-datasets/tfds-nightly version: 1.0.1
  • tensorflow/tensorflow-gpu/tf-nightly/tf-nightly-gpu version: 1.13.1

Reproduction instructions

import tensorflow_datasets as tfds

BATCH_SIZE = 5
dataset = tfds.load('cifar10', as_supervised=True, split=tfds.Split.TEST, batch_size=BATCH_SIZE)
npds = tfds.as_numpy(dataset)

for image, label in npds:
    print(image.shape, label)

Expected behavior The generator npds should return batches of data with the same batch size as dataset.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pat-coadycommented, Aug 12, 2019

Try this instead:

import tensorflow_datasets as tfds

BATCH_SIZE = 5
dataset = tfds.load('cifar10', as_supervised=True, split=tfds.Split.TEST)
dataset = dataset.batch(BATCH_SIZE)
npds = tfds.as_numpy(dataset)

for image, label in npds:
    print(image.shape, label)

I had another strange problem with the batch_size argument. The latest update made my old problem go away, but then I saw the same problem as you.

0reactions
kyleabeauchampcommented, Jul 28, 2019

I’m using python 3.7 and tf2.0 nightly

Read more comments on GitHub >

github_iconTop Results From Across the Web

tensorflow dataset API doesn't work stably when batch size is ...
When I call read_batch_DatasetAPI with batch_size = 1 (see the code below), it can process all (around 200,000) Sequence Examples one-by-one ...
Read more >
How to use Different Batch Sizes when Training and ...
The training batch size will cover the entire training dataset (batch learning) and predictions will be made one at a time (one-step prediction) ......
Read more >
Training & evaluation with the built-in methods - Keras
Introduction. This guide covers training, evaluation, and prediction (inference) models when using built-in APIs for training & validation ...
Read more >
How to use Dataset and Iterators in Tensorflow with code ...
One-shot iterator will iterate through all the elements present in Dataset and once exhausted, cannot be used anymore.
Read more >
tf.keras.Sequential | TensorFlow v2.11.0
Trains the model for a fixed number of epochs (iterations on a dataset). ... in your dataset divided by the batch size, or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found