user3142067
user3142067

Reputation: 1292

Tensorflow CIFAR10 Tutorial: Determining number of epochs in training process

This is probably a very basic question. I' am new to deep learning and from what I gathered until now, one generally creates batches of data and once all the training data has been used (or "enough" of it), the process is repeated a couple of times (each iteration is called an epoch). However, when I look at the tutorial of CIFAR10:

CIFAR10 Tensorflow tutorial

There is no such thing as epochs. They are only mentioned here: cifar10.py

as NUM_EXAMPLES_PER_EPOCH_FOR_TRAIN , NUM_EXAMPLES_PER_EPOCH_FOR_EVAL and NUM_EPOCHS_PER_DECAY.

Do they use this to implicitly define the epochs?

num_batches_per_epoch = NUM_EXAMPLES_PER_EPOCH_FOR_TRAIN /FLAGS.batch_size

I also ask because I'm a bit confused about how i should set the num_epochsargument here (in my own model):

tf.train.string_input_producer(...,num_epochs=num_epochs,...)`

should I just set it to NONE or do I have to calculate the number of epochs first?

Upvotes: 0

Views: 884

Answers (1)

LI Xuhong
LI Xuhong

Reputation: 2356

There are two things in your question:

  1. Understanding: One epoch does not mean one iteration for most situations. One epoch means one pass of the full training set. NUM_EXAMPLES_PER_EPOCH_FOR_TRAIN etc. are defined here as 50000. CIFAR-10 has 50000 examples for training. Then it will be easy to understand num_batches_per_epoch.

  2. As for coding, in tf.train.string_input_producer(...,num_epochs=num_epochs,...), you can check API that explains num_epochs. For CIFAR-10, you don't specify num_epochs (because this string_input_producer does not read each example directly. The database is divided into 5 parts/files, each of which stores 10000 examples, and string_input_producer reads files).

Upvotes: 1

Related Questions