0

I am using TensorFlow for training my own dataset using capsule network. While training mnist dataset, it contains function mnist.train.next_batch(batch size). How to replace this function for training own dataset using TensorFlow?

Armali
  • 18,255
  • 14
  • 57
  • 171
Anusha Mehta
  • 99
  • 1
  • 1
  • 10

1 Answers1

0

The function sample batch_size number of samples from a shuffled training dataset, then return the batch for training.

You could write your own next_batch() method that does the same thing, or modify it as you wish. Then use it similarly when you're training your model.

Kevin Fang
  • 1,966
  • 2
  • 16
  • 31
  • Is it necessory to sample randomly because in that case training images may repeated. Is there any way to sequentially sample batch_size number of images? – Anusha Mehta Jan 02 '19 at 10:02
  • It does sequentially not random. It reshuffles the examples after going through all of them every epoch. Implementation is [here](https://github.com/tensorflow/tensorflow/blob/7c36309c37b04843030664cdc64aca2bb7d6ecaa/tensorflow/contrib/learn/python/learn/datasets/mnist.py#L160) – ARAT Jan 02 '19 at 15:16
  • @AnushaMehta yeah it's shuffle and sample, sort of 'random' I'll edit my answer – Kevin Fang Jan 02 '19 at 22:05
  • @ARAT In the implementation, the function parameter 'self' refer to what? – Anusha Mehta Jan 08 '19 at 09:44
  • It is a keyword/variable in Python. It is used to refer to instance variables. Look [here](https://stackoverflow.com/questions/2709821/what-is-the-purpose-of-self) for more information. – ARAT Jan 08 '19 at 16:52