Why does using the "anfis" function result in invalid values for the membership function?

3 次查看(过去 30 天)
I am using the "anfis" function from the Fuzzy Logic Toolbox in MATLAB R2022b and get the following error message when I try to train a Fuzzy Inference System with a Membership Function of type "trapmf" or "trimf":
Error using fuzzy.internal.utility/validateTriMFParameterValuesFirst parameter must be less than or equal to second parameter.
Shown below is the code I used to train a Fuzzy Inference System with a Membership Function of type "trimf":
% Load data
inputData = tr_data(:,[1:4]);
outputData = tr_data(:,5);
% Trimf ANFIS option config
opt_tri = genfisOptions('GridPartition');
opt_tri.OutputMembershipFunctionType = 'linear';
opt_tri.NumMembershipFunctions = 3;
opt_tri.InputMembershipFunctionType = "trimf";
triAnfis = genfis(inputData,outputData,opt_tri);
triAnfis.andMethod = 'prod';
triOpt = anfisOptions('InitialFis', triAnfis);
triOpt.EpochNumber =  10;
triOpt.InitialStepSize=0.01; 
triOpt.OptimizationMethod=1; % hybrid optimization method
triOpt.ValidationData = ck_data; % set checking data
[triFis,triTrErr,~,triChkFis,triCkErr] = anfis(tr_data,triOpt);
I tried using the "Neuro-Fuzzy Designer" app as well but got the same error message. Why is the "anfis" function setting values for the Membership Function parameters to invalid values?

采纳的回答

MathWorks Support Team
This issue occurs because the "anfis" function does not guarantee convergence for membership functions since each membership function has specific parameter constraints.
The "Neuro-Fuzzy Designer" app utilizes the same "anfis" function as mentioned in your code above, thus we get the same error message:
Error using fuzzy.internal.utility/validateTriMFParameterValuesFirst parameter must be less than or equal to second parameter.
A potential workaround is to change the value of "triOpt.InitialStepSize" to 0.001 from 0.01 in the code provided. This will result in the "anfis" function taking smaller steps thus reducing the probability of choosing invalid membership function parameters.
 
Another workaround is to use the "tunefis" function to tune the Fuzzy Inference System instead of "anfis". This can be achieved by replacing the following line of code:
[triFis,triTrErr,~,triChkFis,triCkErr] = anfis(tr_data,triOpt);
with the lines of code below:
[in,out,rule] = getTunableSettings(triAnfis);
tunefis(triAnfis,rule,inputData,outputData,tunefisOptions("Method","tune_method"));
"getTunableSettings" will provide parameters that are required for the "tunefis" function. The "tunefis" function will then tune the Fuzzy Inference System using the tuning method mentioned in "tunefisOptions". "tunefisOptions" has the following methods to choose from: 
  • "ga" — genetic algorithm
  • "particleswarm" — particle swarm
  • "patternsearch" — pattern search
  • "simulannealbnd" — simulated annealing algorithm
This will allow you to tune the Fuzzy Inference System using alternative methods to "anfis".
For more information on "getTunableSettings", "tunefis" and "tunefisOptions", please refer to the documentation below:
"getTunableSettings" - https://www.mathworks.com/help/releases/R2022b/fuzzy/mamfis.gettunablesettings.html
"tunefis" - https://www.mathworks.com/help/releases/R2022b/fuzzy/tunefis.html
"tunefisOptions" - https://www.mathworks.com/help/releases/R2022b/fuzzy/tunefisoptions.html

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Fuzzy Logic Toolbox 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by