Artificial intelligence 什么';s是神经网络中训练集、验证集和测试集之间的差异?

Artificial intelligence 什么';s是神经网络中训练集、验证集和测试集之间的差异?,artificial-intelligence,neural-network,Artificial Intelligence,Neural Network,我正在使用来实现一个学习代理 我已经生成了培训案例,但我不确定验证和测试集是什么。 老师说: 70%应为培训案例,10%为测试案例,其余20%为验证案例 编辑 我有这个训练代码,但我不知道什么时候停止训练 def train(self, train, validation, N=0.3, M=0.1): # N: learning rate # M: momentum factor accuracy = list() while(True):

我正在使用来实现一个学习代理

我已经生成了培训案例,但我不确定验证和测试集是什么。
老师说:

70%应为培训案例,10%为测试案例,其余20%为验证案例

编辑

我有这个训练代码,但我不知道什么时候停止训练

  def train(self, train, validation, N=0.3, M=0.1):
    # N: learning rate
    # M: momentum factor
    accuracy = list()
    while(True):
        error = 0.0
        for p in train:
            input, target = p
            self.update(input)
            error = error + self.backPropagate(target, N, M)
        print "validation"
        total = 0
        for p in validation:
            input, target = p
            output = self.update(input)
            total += sum([abs(target - output) for target, output in zip(target, output)]) #calculates sum of absolute diference between target and output

        accuracy.append(total)
        print min(accuracy)
        print sum(accuracy[-5:])/5
        #if i % 100 == 0:
        print 'error %-14f' % error
        if ? < ?:
            break
for each epoch
    for each training data instance
        propagate error through the network
        adjust the weights
        calculate the accuracy over training data
    for each validation data instance
        calculate the accuracy over the validation data
    if the threshold validation accuracy is met
        exit training
    else
        continue training

培训和验证集在培训期间使用

  def train(self, train, validation, N=0.3, M=0.1):
    # N: learning rate
    # M: momentum factor
    accuracy = list()
    while(True):
        error = 0.0
        for p in train:
            input, target = p
            self.update(input)
            error = error + self.backPropagate(target, N, M)
        print "validation"
        total = 0
        for p in validation:
            input, target = p
            output = self.update(input)
            total += sum([abs(target - output) for target, output in zip(target, output)]) #calculates sum of absolute diference between target and output

        accuracy.append(total)
        print min(accuracy)
        print sum(accuracy[-5:])/5
        #if i % 100 == 0:
        print 'error %-14f' % error
        if ? < ?:
            break
for each epoch
    for each training data instance
        propagate error through the network
        adjust the weights
        calculate the accuracy over training data
    for each validation data instance
        calculate the accuracy over the validation data
    if the threshold validation accuracy is met
        exit training
    else
        continue training
一旦您完成了培训,您就可以运行测试集并验证准确性是否足够

训练集:此数据集用于调整神经网络上的权重

验证集:此数据集用于最小化过度拟合。您没有使用此数据集调整网络的权重,您只是验证在训练数据集上的任何精度增加实际上都会导致在之前未向网络显示的数据集上的精度增加,或者至少网络没有在其上进行过训练(即验证数据集)。如果训练数据集的准确度增加,但验证数据集的准确度保持不变或降低,则说明神经网络拟合过度,应停止训练

  def train(self, train, validation, N=0.3, M=0.1):
    # N: learning rate
    # M: momentum factor
    accuracy = list()
    while(True):
        error = 0.0
        for p in train:
            input, target = p
            self.update(input)
            error = error + self.backPropagate(target, N, M)
        print "validation"
        total = 0
        for p in validation:
            input, target = p
            output = self.update(input)
            total += sum([abs(target - output) for target, output in zip(target, output)]) #calculates sum of absolute diference between target and output

        accuracy.append(total)
        print min(accuracy)
        print sum(accuracy[-5:])/5
        #if i % 100 == 0:
        print 'error %-14f' % error
        if ? < ?:
            break
for each epoch
    for each training data instance
        propagate error through the network
        adjust the weights
        calculate the accuracy over training data
    for each validation data instance
        calculate the accuracy over the validation data
    if the threshold validation accuracy is met
        exit training
    else
        continue training
测试集:此数据集仅用于测试最终解决方案,以确认网络的实际预测能力

培训集:用于学习的一组示例,即 分类器的参数[即权重]

验证集: 一组示例,用于调整分类器的参数[即结构,而不是权重],例如选择神经网络中隐藏单元的数量

测试集: 仅用于评估完全指定分类器的性能[泛化]的一组示例

来自“什么是总体、样本、培训集、设计集、验证”部分

对于数据集中的不同数据集(批量学习),错误曲面将不同。因此,如果您为测试集数据找到了一个非常好的局部极小值,那么这可能不是一个非常好的点,也可能是由同一问题的其他数据集生成的曲面中的一个非常坏的点。因此,您需要计算这样一个模型,该模型不仅可以为训练集找到一个良好的权重配置,而且还应该能够预测新数据(不在训练集中),并具有良好的误差。换句话说,网络应该能够概括示例,以便学习数据,而不是简单地通过过度拟合训练数据来记忆或加载训练集

验证数据集是您想要学习的功能的一组数据,您不直接使用它来训练网络。您正在使用一组数据对网络进行训练,这些数据称为训练数据集。如果使用基于梯度的算法来训练网络,则误差面和某一点的梯度将完全取决于训练数据集,因此训练数据集直接用于调整权重。为了确保不过度适应网络,需要将验证数据集输入网络,并检查错误是否在某个范围内。由于验证集未直接用于调整网络的权重,因此验证和测试集的良好误差表明网络对列车组示例的预测良好,此外,当向网络提供培训过程中未使用的新示例时,预计其性能良好

早停是停止训练的一种方式。有不同的变化可用,主要的轮廓是,列车和验证集误差都被监控,列车误差在每次迭代(backprop和brothers)时减小,首先验证误差减小。验证错误开始上升时,培训停止。此时的权重配置表示一个模型,该模型可以很好地预测训练数据以及网络看不到的数据。但由于验证数据实际上会间接影响权重配置来选择权重配置。这就是测试集的作用。这组数据从未在培训过程中使用。根据验证集选择模型后,测试集数据将应用于网络模型,并找到该集的错误。这个错误代表了我们可以从同一问题的全新数据中预期的错误

编辑:


此外,如果没有足够的数据用于验证集,则可以使用来调整参数以及估计测试误差。

交叉验证集用于模型选择,例如,为给定参数集选择误差最小的多项式模型。然后使用测试集报告所选模型的泛化错误。从此处开始:

简单地定义培训集、测试集、验证集 训练集:用于查找最近的邻居。 验证集:用于查找适用于列车集的不同k。
测试集:用于查找最大精度和将来看不见的数据。

假设您在训练集上训练模型,然后在测试集上测量其性能。您认为仍有改进的余地,并尝试调整超参数(如果模型是神经网络-超参数是层数或层中的节点数)。现在你的表现稍微好一点。但是,当模型使用其他数据(不在测试和训练集中)时,您可能无法获得相同的精度级别。这是因为在调整“超参数”时引入了一些偏差