训练多层感知器时,历元和迭代的区别是什么?


当前回答

一个epoch包含几个迭代。这就是这个时代。让我们把epoch定义为训练神经网络时在数据集上的迭代次数。

其他回答

我想在神经网络术语的背景下:

Epoch:当你的网络最终遍历整个训练集(即,每个训练实例一次)时,它完成了一个Epoch。

为了定义迭代(也就是步骤),你首先需要知道批处理的大小:

Batch Size: You probably wouldn't like to process the entire training instances all at one forward pass as it is inefficient and needs a huge deal of memory. So what is commonly done is splitting up training instances into subsets (i.e., batches), performing one pass over the selected subset (i.e., batch), and then optimizing the network through backpropagation. The number of training instances within a subset (i.e., batch) is called batch_size. Iteration: (a.k.a training steps) You know that your network has to go over all training instances in one pass in order to complete one epoch. But wait! when you are splitting up your training instances into batches, that means you can only process one batch (a subset of training instances) in one forward pass, so what about the other batches? This is where the term Iteration comes into play: Definition: The number of forwarding passes (The number of batches that you have created) that your network has to do in order to complete one epoch (i.e., going over all training instances) is called Iteration.

例如,当你有10,000个训练实例,你想用10的大小进行批处理;你必须进行10,000/10 = 1,000次迭代才能完成1个epoch。

希望这能回答你的问题!

时代 对整个数据集进行完整的训练,使得每个 例子已经见过一次了。因此,一个epoch表示N/batch 大小训练迭代,其中N是的总数 的例子。 迭代 在训练过程中对模型权重的一次更新。 迭代包括计算参数的梯度 对于单批数据的损失。

奖金:

批处理 在一次迭代中使用的示例集(即一个梯度) 更新)的模型训练。 请参见批大小。

来源:https://developers.google.com/machine-learning/glossary/

在神经网络术语中:

一个epoch =所有训练示例的一个向前传递和一个向后传递 批大小=一次向前/向后传递中训练示例的数量。批处理大小越大,所需的内存空间就越大。 迭代次数=通过次数,每次通过使用[批大小]示例的数量。需要明确的是,一次传球=一次向前传球+一次向后传球(我们不把向前传球和向后传球算作两次不同的传球)。

例如:如果你有1000个训练样本,你的批处理大小是500,那么将需要2次迭代来完成1个epoch。

供参考:权衡批大小和迭代次数来训练神经网络


术语“批处理”是模棱两可的:有些人用它来表示整个训练集,有些人用它来指代一次向前/向后传递中的训练示例的数量(就像我在这个回答中所做的那样)。为了避免这种歧义,并明确batch对应于一次正向/向后传递中训练示例的数量,可以使用术语mini-batch。

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).