Training ANN and gaining RMSE values

7 次查看(过去 30 天)
Hi all,
I am trying to create and train an ANN to predict power output of a wind turbine based on some inputs. I have followed a helpful video on youtube on how to create the ANN and return RMSE values for the training, validation and test cycles of the ANN. The problem I am having is that when I run the code, one of my RMSE values comes back as a NaN. The data used is a numeric Matrix obtained from a simulation and contains no NaN's at all. What is more problematic is that if I run the code 3 times consecutivly, each time a differant RMSE value returns the NaN. Please see code below:
%data
x=winddata(:,[2 5 17 20]);
y=winddata(:,22);
m=length(y);
%Train ANN
xt=x';
yt=y';
hiddenlayersize=10;
net=fitnet(hiddenlayersize);
net.divideParam.trainRatio=30/100;
net.divideParam.ValRatio=30/100;
net.divideParam.testRatio=40/100;
[net,tr]=train(net, xt, yt);
yTrain=net(xt(:,tr.trainInd));
yTrainTrue=yt(tr.trainInd);
rmse_train=sqrt(mean((yTrain-yTrainTrue).^2))
yVal=net(xt(:,tr.valInd));
yValTrue=yt(tr.valInd);
rmse_val=sqrt(mean((yVal-yValTrue).^2))
yTest=net(xt(:,tr.testInd));
yTestTrue=yt(tr.testInd);
rmse_test=sqrt(mean((yTest-yTestTrue).^2))
The results obtained from running the ANN 3 times consecutivly can be seen below:
>> ANNcheck1
rmse_train = NaN
rmse_val = 292.1152
rmse_test = 290.5616
>> ANNcheck2
rmse_train = 290.6516
rmse_val = 290.7914
rmse_test = NaN
>> ANNcheck3
rmse_train = NaN
rmse_val = 289.9657
rmse_test = 293.0484
Any help would be greatly appreciated!

采纳的回答

Matt Egan
Matt Egan 2021-2-8
I have found the error in the code! It was to do with the transposition from of the matricies, this is what I had:
xt=x';
yt=y';
And this is what it should be:
xt=x.';
yt=y.';

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dimensionality Reduction and Feature Extraction 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by