时代和训练步骤是一回事吗? [英] Are epochs and training steps the same thing?

查看:73
本文介绍了时代和训练步骤是一回事吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

features = [tf.contrib.layers.real_valued_column("x", dimension=1)]
estimator = tf.contrib.learn.LinearRegressor(feature_columns=features)
y = np.array([0., -1., -2., -3.])
input_fn = tf.contrib.learn.io.numpy_input_fn({"x":x}, y, batch_size=4,
                                              num_epochs=1000)

estimator.fit(input_fn=input_fn, steps=1000)

例如,这些"steps = 1000"和"num_epochs = 1000"是否完全相同?如果是,为什么需要重复?如果没有,我可以不同地设置这两个参数吗?

For example, do these "steps=1000" and "num_epochs=1000" mean exactly the same thing? If yes, why does it need to be duplicated? If not, can i set these two parameters differently?

推荐答案

以下是任何机器学习算法或框架中的纪元与步骤之间的基本区别:

Here is the basic difference between epoch and steps in any machine learning algorithm or framework:

一旦框架遍历其训练集中的所有数据点以更新其参数,则称为一个时期.步骤之一是参数的更新(例如,如果训练DNN,则神经网络的权重).可以使用单个数据点或小批量数据点(例如,随机绘制100个数据点,有或没有替换)或所有这些点来获得此更新.因此,如您所见,如果您的所有数据点都在一个步骤中使用(或更新参数),则它变成一个时期,即一个步骤=一个时期.

Once the framework goes through all the data points in its training set to update its parameters it's called one epoch. A step is one update of the parameters (e.g. weights of the neural network if it training DNN). This update can be obtained using a single data point, or a mini-batch of data points (e.g. randomly drawing 100 data points, with or without replacement), or all the points. Hence as you can see if all your datapoints are used in one step (or update of parameters) it becomes one epoch i.e. one step = one epoch.

通常,框架使用迷你批处理,并且在一个步骤中,它们将100个(或其他一些数量)数据点一起批处理并进行一次更新.在这种情况下,如果说您总共有100万个数据点(10 ^ 6),则一个时期有10000个步骤,因为一个步骤包含100个数据点.

Typically frameworks use mini-batching and in one step they batch 100 (or some other number) datapoints together and do one update. In this case, if say you have total 1 million datapoints (10^6) then one epoch has 10000 steps since one step contains 100 datapoints.

这篇关于时代和训练步骤是一回事吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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