Gaussian membership function must have nonzero sigma value
12 views (last 30 days)
Show older comments
I have a data matrix and I want to train ANFIS with that, and I used genfis3 for inital fis.
But matlab gives Warning:
Warning: Rank deficient, rank = 29, tol = 1.981365e-09.
> In genfis3>computemfparams (line 222)
In genfis3 (line 170)
when genfis3 runs and error :
Error using fuzzy.internal.fis.FuzzyInferenceSystem/addMF (line 1090)
Gaussian membership function must have nonzero sigma value.
Error in fuzzy.internal.utility.createFromStruct (line 43)
fisout = addMF(fisout,fisout.Inputs(i).Name, ...
Error in convertfis (line 25)
fisout = fuzzy.internal.utility.createFromStruct(fisin);
Error in anfis>trainFIS (line 225)
t_fismat = convertfis(t_fismat);
Error in anfis>anfisWithOptionalInputs (line 347)
[varargout{1:nargout}] = trainFIS(trn_data, in_fismat, t_opt, d_opt, ...
Error in anfis (line 69)
[varargout{1:nargout}] = anfisWithOptionalInputs(trn_data,varargin{:});
occurs when performing ANFIS.
my code:
%Design ANFIS
load(TrainFeature.mat);
load(TrainTargets.mat);
nCluster=10;
Exponent=2;
MaxIt=100;
MinImprovment=1e-5;
DisplayInfo=1;
FCMOptions=[Exponent MaxIt MinImprovment DisplayInfo];
fis=genfis3(TrainFeature,TrainTargets,'sugeno',nCluster,FCMOptions);
MaxEpoch=100;
ErrorGoal=0;
InitialStepSize=0.01;
StepSizeDecreaseRate=0.9;
StepSizeIncreaseRate=1.1;
TrainOptions=[MaxEpoch ...
ErrorGoal ...
InitialStepSize ...
StepSizeDecreaseRate ...
StepSizeIncreaseRate];
DisplayInfo=true;
DisplayError=true;
DisplayStepSize=true;
DisplayFinalResult=true;
DisplayOptions=[DisplayInfo ...
DisplayError ...
DisplayStepSize ...
DisplayFinalResult];
OptimizationMethod=1;
% 0: Backpropagation
% 1: Hybrid
fis=anfis([TrainFeature TrainTargets],fis);
I'll be grateful if anyone tells me the reason for this error and warning ....
2 Comments
Answers (2)
milad eshkevari
on 29 Dec 2021
Hello dear friends. I also encountered a similar error in my work. By trial and error, I realized the reason and the way to fix the error. This error occurs when one of the inputs (features) is not properly dispersed and changed. In other words, one of the inputs was almost the same for all samples. To solve this problem, you can easily identify and delete an inappropriate input or feature with a near-zero variance by ploting the membership functions of each of the inputs (before using anfis and after using genfis). For example, in my code, after executing the genfis3 command, I plot the membership function for each of the inputs.
nMFs=4;
InputMF='gaussmf';
OutputMF='linear';
fis=genfis3(XTrain, YTrain, 'sugeno', Iter); %
% Plot MFs before training with anfis
plotmf(fis,'input',7)
My input number 7, as you can see in the figure, had a variance close to zero.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/846645/image.jpeg)
For comparison, I also plot MF of the inputs 1 and 3 below to see what the proper input should look like.
figure; plotmf(fis,'input',1)
figure; plotmf(fis,'input',3)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/846650/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/846655/image.jpeg)
I deleted column 7 of my input data and this error was fixed.
XTrain(:,7) = [];
MGH
on 6 Aug 2020
Dear Vahab,
Did you solve the problem? I have the same issue and cannot solve it. In the case you solved your issue, can you please tell me how you did that?
Thanks in advance,
Masoud
1 Comment
Pranshuta Shukla
on 13 Jul 2021
Dear Vahab and MGH,
Did you solve the problem? I have the same issue and cannot solve it. In the case you solved your issue, can you please tell me how you did that?
Thanks in advance,
Pranshuta
See Also
Categories
Find more on Fuzzy Logic Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!