Inconsistent/Different 在 Matlab 中训练神经网络后测试 Performance/Error

Inconsistent/Different Test Performance/Error After Training Neural Network in Matlab

保持所有参数不变,我在重新训练神经网络的测试数据上得到了不同的平均百分比误差。为什么会这样?神经网络训练过程的所有组成部分不是确定性的吗?有时,我发现连续训练的差异高达 1%。

训练代码如下

netFeb = newfit(trainX', trainY', networkConfigFeb);
netFeb.performFcn = 'mae';
netFeb = trainlm(netFeb, trainX', trainY');

% Index for the testing Data
startingInd = find(trainInd == 0, 1, 'first');
endingInd = startingInd + daysInMonth('Feb') - 1 ;

% Testing Data
testX = X(startingInd:endingInd,:);
testY = dailyPeakLoad(startingInd:endingInd,:);
actualLoadFeb = testY;

% Calculate the Forcast Load and the Mean Absolute Percentage Error
forecastLoadFeb = sim(netFeb, testX'';
errFeb = testY - forecastLoadFeb;
errpct = abs(errFeb)./testY*100;
MAPEFeb = mean(errpct(~isinf(errpct)));

正如 A. Donda 暗示的那样,由于神经网络随机初始化它们的权重,因此它们在训练后会生成不同的网络。因此,它将为您提供不同的性能。虽然训练过程是确定性的,但初始值不是!结果,您可能会到达不同的局部最小值或停在不同的地方。

如果您想了解原因,请查看 Why should weights of Neural Networks be initialized to random numbers?

编辑 1:

备注

  • 由于用户手动定义 testing/training 数据,因此所选训练数据集没有随机化