Warning: MATLAB may run out of memory if this FIS is tuned using ANFIS
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to train an ANFIS structure. I have 8 inputs and one corrosponding output. When I train these data with "anfis" function, I will get the following error :
Warning: Generated rule base is large. MATLAB may run out of memory if this FIS is tuned using ANFIS.
> In genfis1 (line 161)
In genfis (line 61)
In ANFIS (line 39)
ANFIS info:
Number of nodes: 555
Number of linear parameters: 2304
Number of nonlinear parameters: 48
Total number of parameters: 2352
Number of training data pairs: 501
Number of checking data pairs: 0
Number of fuzzy rules: 256
Warning: Number of training data is smaller than number of modifiable parameters.
> In anfis>trainFIS (line 190)
In anfis>anfisWithOptionalInputs (line 326)
In anfis (line 69)
In ANFIS (line 40)
Start training ANFIS ...
And the result will go to infinity. Note that I do not want to scale my data and I need the corrosponding output which is a vector, the values of which should be between zero and one. What should I do to solve this problem ?
the following is my ANFIS code :
clc;clear;close all;
%% 1. Load Data
Data = load('data_0_to_50_smooth');
t = Data.t;
u1 = Data.u1; % Vaccination
u2 = Data.u2; % Social Distancing
u3 = Data.u3; % TreatMent Rate
states = Data.y;
states = states';
data1 = [states u1];
data2 = [states u2];
data3 = [states u3];
%% 2. Create First FiS
NumMfs = 2;
InMfsType ='trimf';
OutMfsType = 'linear';
Xin1 = data1(:,1:end-1);
Xout1 = data1(:,end);
radii = 0.2;
EpochNumber = 100;
ErrorGoal = 0.001;
StepSize =0.35;
StepSizeDecreaseRate =0.85;
StepSizeIncreaseRate = 1.15;
TrainOptions = [EpochNumber,ErrorGoal,...
StepSize,StepSizeDecreaseRate,...
StepSizeIncreaseRate];
% Fis1 = genfis1(data1,NumMfs,InMfsType,OutMfsType);
Fis1 = genfis(data1(:,1:end-1),data1(:,end));
Fis1 = anfis(data1,Fis1);
out1 = evalfis(Fis1,data(:,1:end-1),TrainOptions);
The data I used for this problem is attached.
1 commentaire
Réponses (1)
Sam Chak
le 15 Avr 2025
If you use the "Grid Partitioning" method for the nine inputs in ANFIS training, MATLAB may run out of memory due to the excessive number of parameters and rules that need to be tuned over 100 epochs. Instead, for relatively large datasets with more than two inputs, I typically use the "Subtractive Clustering" method.
In the demo below, which predicts the u1 signal, the raw data are normalized to improve the condition number and training efficiency, resulting in only three fuzzy rules and a root mean square error (rmse) of 0.00055. Also check out the zipped FIS file.
%% Step 1. Load Data
Data = load('data_0_to_50_smooth');
t = Data.t;
u1 = Data.u1; % Vaccination
u2 = Data.u2; % Social Distancing
u3 = Data.u3; % TreatMent Rate
states = Data.y;
states = states';
data1 = [states u1];
data2 = [states u2];
data3 = [states u3];
% figure
% plot(t, states)
% figure
% plot(t, u1)
% figure
% plot(t, u2)
% figure
% plot(t, u3)
%% Step 2. Process the data
% Xin1 = data1(:, 1:end-1); % raw 8 states data
% normalization of data
state1 = states(:,1)/max(states(:,1));
state2 = states(:,2)/max(states(:,2));
state3 = states(:,3)/max(states(:,3));
state4 = states(:,4)/max(states(:,4));
state5 = states(:,5)/max(states(:,5));
state6 = states(:,6)/max(states(:,6));
state7 = states(:,7)/max(states(:,7));
state8 = states(:,8)/max(states(:,8));
Xin1 = [state1, state2, state3, state4, state5, state6, state7, state8];
% figure
% plot(t, Xin1)
% Xout1 = data1(:,end); % raw u1 data
Xout1 = 0.1*data1(:,end)/max(data1(:,end));
dataTr = [Xin1, Xout1];
connum = cond(dataTr)
%% Step 3. Get ready with ANFIS
% create initial FIS
genOpt = genfisOptions('SubtractiveClustering');
iniFIS = genfis(Xin1, Xout1, genOpt);
% train data via ANFIS
anfOpt = anfisOptions('InitialFIS', iniFIS, 'EpochNumber', 1000);
outFIS = anfis(dataTr, anfOpt)
%% Step 4. Plot result
figure
Yout1 = evalfis(outFIS, Xin1);
plot(t, [data1(:,end), Yout1*max(data1(:,end))/0.1]), grid on
xlabel('t'), ylabel('u_1')
legend('Training Data', 'ANFIS Output')
title('ANFIS Predictions of u_1')
%% Step 5. Access to trained ANFIS
% fuzzy(outFIS)
% fuzzyLogicDesigner(outFIS)


0 commentaires
Voir également
Catégories
En savoir plus sur Fuzzy Inference System Tuning dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!