필터 지우기
필터 지우기

Training ANN and gaining RMSE values

조회 수: 7 (최근 30일)
Matt Egan
Matt Egan 2021년 2월 7일
답변: Matt Egan 2021년 2월 8일
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