user270700
user270700

Reputation: 759

How to use a portion of existing dataset in Tensorflow

I want to use only first 10% of each class of CIFAR10 dataset in tensorflow resnet example code.

In this case, what is the most simple way to change? I don't exactly understand the data class in Tensorflow...

Upvotes: 1

Views: 68

Answers (1)

Maxim
Maxim

Reputation: 53758

Filtering the dataset exactly 10% per class can be a bit hairy, but if your goal is just to try ResNet on a smaller dataset, the simplest way is to skip 90% of the dataset, which will reduce each class approximately to 10%. If this is ok for you, simply add skip after the shuffle call:

...
dataset = dataset.shuffle(buffer_size=_SHUFFLE_BUFFER)
dataset = dataset.skip(54000)
...

.. which will cause the dataset to skip 90% of 60000 examples and return only 6000.

Upvotes: 1

Related Questions