训练多层感知器时,历元和迭代的区别是什么?
当前回答
epoch是用于训练的样本子集的迭代,例如,神经网络中的梯度下降算法。一个很好的参考:http://neuralnetworksanddeeplearning.com/chap1.html
请注意,该页面有一个使用epoch的梯度下降算法的代码
def SGD(self, training_data, epochs, mini_batch_size, eta,
test_data=None):
"""Train the neural network using mini-batch stochastic
gradient descent. The "training_data" is a list of tuples
"(x, y)" representing the training inputs and the desired
outputs. The other non-optional parameters are
self-explanatory. If "test_data" is provided then the
network will be evaluated against the test data after each
epoch, and partial progress printed out. This is useful for
tracking progress, but slows things down substantially."""
if test_data: n_test = len(test_data)
n = len(training_data)
for j in xrange(epochs):
random.shuffle(training_data)
mini_batches = [
training_data[k:k+mini_batch_size]
for k in xrange(0, n, mini_batch_size)]
for mini_batch in mini_batches:
self.update_mini_batch(mini_batch, eta)
if test_data:
print "Epoch {0}: {1} / {2}".format(
j, self.evaluate(test_data), n_test)
else:
print "Epoch {0} complete".format(j)
看看代码。对于每个历元,我们随机生成梯度下降算法输入的子集。为什么epoch是有效的,也解释了这一页。请看一看。
其他回答
你有训练数据,你洗牌并从中挑选小批量。当您使用一个迷你批处理调整权重和偏差时,您已经完成了一次迭代。
一旦你用完了你的小批,你就完成了一个纪元。然后你再次洗牌你的训练数据,再次选择你的小批量,并再次遍历它们。那将是你的第二个纪元。
Epoch is 1 complete cycle where the Neural network has seen all the data. One might have said 100,000 images to train the model, however, memory space might not be sufficient to process all the images at once, hence we split training the model on smaller chunks of data called batches. e.g. batch size is 100. We need to cover all the images using multiple batches. So we will need 1000 iterations to cover all the 100,000 images. (100 batch size * 1000 iterations) Once Neural Network looks at the entire data it is called 1 Epoch (Point 1). One might need multiple epochs to train the model. (let us say 10 epochs).
通常,你会把你的测试集分成小批,让网络从中学习,并让训练在你的层数中一步一步地进行,一直应用梯度下降。所有这些小步骤都可以称为迭代。
一个epoch对应于整个训练集通过整个网络一次。限制这种情况是很有用的,例如对抗过拟合。
时代 对整个数据集进行完整的训练,使得每个 例子已经见过一次了。因此,一个epoch表示N/batch 大小训练迭代,其中N是的总数 的例子。 迭代 在训练过程中对模型权重的一次更新。 迭代包括计算参数的梯度 对于单批数据的损失。
奖金:
批处理 在一次迭代中使用的示例集(即一个梯度) 更新)的模型训练。 请参见批大小。
来源:https://developers.google.com/machine-learning/glossary/
我认为迭代相当于批SGD中的单批正向+反向。Epoch将遍历整个数据集一次(正如其他人提到的那样)。
推荐文章
- 主体、使用者和主体之间的意义和区别是什么?
- 什么是分片,为什么它很重要?
- 我在哪里调用Keras的BatchNormalization函数?
- 编程中的术语“上下文”?
- model.eval()在pytorch中做什么?
- 为什么binary_crossentropy和categorical_crossentropy对同一个问题给出不同的性能?
- 覆盖或覆盖
- 火灾vs. Webservice
- 为什么使用softmax而不是标准归一化?
- 为什么两个不同的概念都叫“堆”?
- 一般来说,应该选择哪种机器学习分类器?
- Keras,如何得到每一层的输出?
- 缓冲区是什么意思?
- 是否可以使用scikit-learn K-Means聚类来指定自己的距离函数?
- 批量归一化和退出的排序?