我需要在matlab中得到anfis中输入的隶属函数的范围。我使用以下代码来训练我的网络,并成功地训练网络。但我需要的是获得网络为输入的隶属函数找到的范围的值。我的意思是,如果一个隶属函数是钟形的,比如gbellmf,它的公式是(x)= exp{-((x-c)/a)^(2*b)},我需要在网络训练后知道a,b和c的值。
function trainedfis = main(data,chkdata)
fis = genfis1(data,[3 3 3],char('gbellmf','gbellmf', 'gbellmf'));
[trainedfis,errors,stepssize,chkfis,errchk] = anfis(data,fis,3,[1 1 1 1],chkdata);
end另外,我的数据是三个输入和一个输出数据(3列用于输入,1列用于输出)。我使用matlab内置的genfis1和anfis。
发布于 2020-09-30 05:29:59
您可以通过以下方式访问i-th input的j-th隶属函数的所有参数:
fis.input(i).mf(j).params在下面的例子中,我训练了虹膜数据的fis,它有4个输入。然后,我使用存储在fismat中的数据绘制所有隶属函数:
close all; clc; clear variable;
%% import iris data
[x, t] = iris_dataset;
y = t(1, :)*1 + t(1, :)*2 + t(3, :)*3;
data = [x' y'];
%% train fis moddel
numMFs = [3 3 3 3];
mfType = char('gbellmf','gbellmf', 'gbellmf', 'gbellmf');
fismat = genfis1(data,numMFs,mfType);
%% plot input membership function using plotmf
subplot(2,2,1), plotmf(fismat,'input',1);
subplot(2,2,2), plotmf(fismat,'input',2);
subplot(2,2,3), plotmf(fismat,'input',3);
subplot(2,2,4), plotmf(fismat,'input',4);
%% plot input membership function manually, using fismat object
figure;
% get number of inputs
ni = numel(fismat.input);
for i=1:ni
% get total range of all mem-funs of i-th input
range = fismat.input(i).range;
subplot(2, 2, i);
xlabel(['input ' num2str(i)]);
xlim(range); hold on;
x = linspace(range(1), range(2), 100);
% get number of mem-funs of i-th input
nmf = numel(fismat.input(i).mf);
for j=1:nmf
% get j-th mem-fun of i-th input
mf = str2func(fismat.input(i).mf(j).type);
% get parameters of j-th mem-fun of i-th input
params = fismat.input(i).mf(j).params;
y = mf(x, params);
plot(x, y, 'displayname', ...
[fismat.input(i).mf(j).type '(' num2str(params, '%.1f,') ')']);
end
legend('show')
end

https://stackoverflow.com/questions/64125683
复制相似问题