TensorFlow中的步骤和纪元之间有什么区别? [英] What is the difference between steps and epochs in TensorFlow?

查看:62
本文介绍了TensorFlow中的步骤和纪元之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在大多数模型中,都有一个 steps 参数,该参数指示要运行数据的步骤数.但是,我发现在最实际的用法中,我们还执行了拟合函数N epochs .

In most of the models, there is a steps parameter indicating the number of steps to run over data. But yet I see in most practical usage, we also execute the fit function N epochs.

以1个时间段运行1000个步和以10个时间段运行100个步有什么区别?在实践中哪一个更好?在连续的历元之间有任何逻辑变化吗?数据改组?

What is the difference between running 1000 steps with 1 epoch and running 100 steps with 10 epoch? Which one is better in practice? Any logic changes between consecutive epochs? Data shuffling?

推荐答案

时期通常意味着对所有训练数据进行一次迭代.例如,如果您有20,000张图像且批处理大小为100,则纪元应包含20,000/100 = 200步.但是,即使我有更大的数据集,我通常也只设置固定的步骤数,例如每个时期1000.在该阶段结束时,我检查平均费用,如果费用有所改善,则保存一个检查点.从一个纪元到另一个纪元的步骤之间没有区别.我只是把它们当作检查点.

An epoch usually means one iteration over all of the training data. For instance if you have 20,000 images and a batch size of 100 then the epoch should contain 20,000 / 100 = 200 steps. However I usually just set a fixed number of steps like 1000 per epoch even though I have a much larger data set. At the end of the epoch I check the average cost and if it improved I save a checkpoint. There is no difference between steps from one epoch to another. I just treat them as checkpoints.

人们经常在各个时期之间对数据集进行洗牌.我更喜欢使用random.sample函数来选择要在我的时代处理的数据.假设我要以32个批次的大小执行1000步.我将从训练数据池中随机抽取32,000个样本.

People often shuffle around the data set between epochs. I prefer to use the random.sample function to choose the data to process in my epochs. So say I want to do 1000 steps with a batch size of 32. I will just randomly pick 32,000 samples from the pool of training data.

这篇关于TensorFlow中的步骤和纪元之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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