- Generalized Regression Neural Networks: https://www.mathworks.com/help/deeplearning/ug/generalized-regression-neural-networks.html
- Design generalized regression neural network: https://www.mathworks.com/help/deeplearning/ref/newgrnn.html
- Process matrices by mapping row minimum and maximum values to [-1 1]: https://www.mathworks.com/help/deeplearning/ref/mapminmax.html
why my training results are repeated even after i run my code again and again ??
1 view (last 30 days)
Show older comments
% 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 !!!!
0 Comments
Answers (1)
Himanshu
on 9 Aug 2024
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.
I hope this helps.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!