Plot performance of validation and test set (gives NaN)

Hi, I want to train a feedforward neural net. I split my data in 3 equally large sets for training, validation and testing. After training I want to show performance on the 3 test sets. Problem is, plotperform() only shows my training MSE and when calling tr.best_tperf I get 'NaN'. Below is my code, does anyone know what is the problem?
RandomIndex = randperm(length(X1),3000);
X1_train = X1(RandomIndex);
X2_train = X2(RandomIndex);
Tnew_train = Tnew(RandomIndex);
net = feedforwardnet(10, 'trainlm');
net.divideParam.trainRatio = 1/3;
net.divideParam.valRatio = 1/3;
net.divideParam.testRatio = 1/3;
net.trainParam.epochs = 10;
net.layers{1}.transferFcn = 'logsig';
[net,tr] = train(net, p_train, t_train);
plotperform(tr);

답변 (1개)

Jayanti
Jayanti 2025년 7월 3일
Hi Alexs,
As per the given code you are manually selecting a shuffled subset of 3000 samples using "randperm", but you later call the "train()" function with p_train" and "t_train", which are not defined in the code and may not include the full dataset required for MATLAB to automatically split it into training, validation, and testing subsets.
If the inputs passed to "train()" contain only training data, the validation and test subsets might become extremly small or empty, resulting in Nan values and incomplete performance plots.
To avoid this try providing your complete, undivided input and target datasets to the "train()" function. MATLAB will then handle the 1/3, 1/3, 1/3 split internally based on your "net.divideParam" settings.
You can update your code as below:
% Prepare input data
P_all = [X1; X2];
T_all = Tnew;
% Train with complete Dataset
[net,tr] = train(net, P_all, T_all);
Happy coding!

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

태그

질문:

2018년 5월 16일

답변:

2025년 7월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by