gpt4 book ai didi

java - Encog - 带验证集的 EarlyStoppingStrategy

转载 作者:行者123 更新时间:2023-11-30 03:40:54 25 4
gpt4 key购买 nike

一旦我看到从验证集计算出的误差开始增加,我想停止训练网络。我使用带有 RPROP 的 BasicNetwork 作为训练算法,并且进行以下训练迭代:

double validationError = 999.999;


while(!stop){

train.iteration(); //weights are updated here

System.out.println("Epoch #" + epoch + " Error : " + train.getError()) ;

//I'm just comparing to see if the error on the validation set increased or not
if (network.calculateError(validationSet) < validationError)
validationError = network.calculateError(validationSet);

else
//once the error increases I stop the training.
stop = true ;

System.out.println("Epoch #" + epoch + "Validation Error" + network.calculateError(validationSet));

epoch++;

}
train.finishTraining();

显然这是行不通的,因为在确定我是否需要停止训练之前权重已经改变了。我是否可以退一步并使用旧的权重?

我还看到了 EarlyStoppingStrategy 类,这可能是我需要通过使用 addStrategy() 方法来使用的类。但是,我真的不明白为什么 EarlyStoppingStrategy 构造函数同时采用验证集和测试集。我认为它只需要验证集,并且在测试网络的输出之前根本不应该使用测试集。

最佳答案

Encog 的 EarlyStoppingStrategy 类根据本文实现了提前停止策略:

探针1 |一组神经网络基准问题和基准规则

(完整的引用包含在 Javadoc 中)

如果您只想在验证集的错误不再改善时立即停止,您可能只想使用 Encog SimpleEarlyStoppingStrategy,可在此处找到:

org.encog.ml.train.strategy.end.SimpleEarlyStoppingStrategy

请注意,SimpleEarlyStoppingStrategy 需要 Encog 3.3。

关于java - Encog - 带验证集的 EarlyStoppingStrategy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26853922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com