简体   繁体   中英

What are 'batches' and 'steps' in TensorFlow Estimators and how do they differ from epochs?

I am attempting to use TensorFlow's Estimators. In the documentation the following code is used to train and evaluate the network.

# Fit
nn.fit(x=training_set.data, y=training_set.target, steps=5000)

# Score accuracy
ev = nn.evaluate(x=test_set.data, y=test_set.target, steps=1)
loss_score = ev["loss"]
print("Loss: %s" % loss_score)

The whole training set is passed in, but we have steps=5000 . Does this mean that only the first 5000 examples from the set are considered?

What does the batch_size parameter mean in this context, and how does it interact with steps ?

Thanks!

batch_size is the number of examples processed at once. TF pushes all of those through one forward pass (in parallel) and follows with a back-propagation on the same set. This is one iteration , or step .

The steps parameter tells TF to run 5000 of these iterations to train the model.

One epoch is treating each example in the training set exactly once. For instance, if you have one million examples and a batch size of 200, then you need 5000 steps to one epoch: 200 * 5.000 = 1.000.000

Does that clear up the terminology?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM