什么是 TensorFlow Estimators 中的“batches"和“steps"?它们与 epochs 有何不同? [英] What are 'batches' and 'steps' in TensorFlow Estimators and how do they differ from epochs?

查看:12
本文介绍了什么是 TensorFlow Estimators 中的“batches"和“steps"?它们与 epochs 有何不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 TensorFlow 的估算器.在文档中,以下代码用于训练和评估网络.>

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)

整个训练集都传入了,但是我们有steps=5000.这是否意味着只考虑集合中的前 5000 个示例?

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?

batch_size 参数在此上下文中的含义是什么,它如何与 steps 交互?

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

谢谢!

推荐答案

batch_size 是一次处理的示例数量.TF 通过一次前向传递(并行)推动所有这些,然后在同一组上进行反向传播.这是一个迭代,或步骤.

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.

steps 参数告诉 TF 运行 5000 次迭代来训练模型.

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

一个 epoch 对训练集中的每个样本只处理一次.例如,如果您有 100 万个示例和 200 个批次,那么您需要 5000 步到一个时期:200 * 5.000 = 1.000.000

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

这是否澄清了术语?

这篇关于什么是 TensorFlow Estimators 中的“batches"和“steps"?它们与 epochs 有何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆