why my training results are repeated even after i run my code again and again ??

1 次查看(过去 30 天)
% ANN model for ukraine with all inputs
%% Data loading to the matlab environment
train_data = xlsread('Train_M.xlsx');
input_train = xlsread('Train_M','input');
X_train = input_train';
target_train = xlsread('Train_M','target');
T_train = target_train';
test_data = xlsread('Test_M.xlsx');
input_test = xlsread('Test_M','input');
X_test = input_test';
target_test = xlsread('Test_M','target');
T_test = target_test';
%% normalization of training and testing data
%for training
[Tr_i ps] = mapminmax(X_train,-1,1);
[Tr_t ps] = mapminmax(T_train,-1,1);
%for testing
[Tst_i pp] = mapminmax(X_test,-1,1);
[Tst_t pp] = mapminmax(T_test,-1,1);
%clear
%clc
%load Best_Dataset (need to save our datadivision for avoiding
%randomization)
%% GRNN model development
%% model formulation
spread = 0.42;
net = newgrnn(Tr_i,Tr_t,spread);
view(net);
%% prediction outputs of the model
y_tr = net(Tr_i);
y_tst = net(Tst_i);
%% renormalization process
% Model outputs(forecasted data)
Renorm_train_out = mapminmax('reverse',y_tr,ps);
Renorm_test_out = mapminmax('reverse',y_tst,pp);
%for model inputs(observed data)
Renorm_train_inp = mapminmax('reverse',Tr_t,ps);
Renorm_test_inp = mapminmax('reverse',Tst_t,pp);
%% performance of the ANN model
%Training performance and testing performance
plot(Renorm_test_inp,Renorm_test_out,'x')%curves is ok
plot(Renorm_train_inp,Renorm_train_out,'x')%curve is ok
%% statistical measure of the model
%% model performance command
mdl = fitlm(Renorm_test_inp,Renorm_test_out)%testing performance
mdl = fitlm(Renorm_train_inp,Renorm_train_out)%training performance
%% saving the trained model
save('GRNN_allinputs.mat','net');
%% the results for the above code repeates.
R2 is 0.68, RMSE 10.8 - training
R2 is 0.639 ,RMSE 3.03 -testing
these results are again shown for the second run and so on
AM i missing something here ???
please help !!!!

回答(1 个)

Himanshu
Himanshu 2024-8-9
Hi,
I see that you are facing repeated training results even after running your code multiple times.
The reason behind this is likely due to the deterministic nature of the Generalized Regression Neural Network (GRNN). GRNN does not have random initialization, so it will always produce the same results given the same inputs. Ensure that data normalization is consistent and correctly applied to avoid any discrepancies.
Please refer to the below documentations for more information.
  1. Generalized Regression Neural Networks: https://www.mathworks.com/help/deeplearning/ug/generalized-regression-neural-networks.html
  2. Design generalized regression neural network: https://www.mathworks.com/help/deeplearning/ref/newgrnn.html
  3. Process matrices by mapping row minimum and maximum values to [-1 1]: https://www.mathworks.com/help/deeplearning/ref/mapminmax.html
I hope this helps.

类别

Help CenterFile Exchange 中查找有关 Support Vector Machine Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by