Genetic algorithm in convolution nueral network

조회 수: 1 (최근 30일)
asmaa hekal
asmaa hekal 2019년 4월 25일
댓글: souhila mehellou 2019년 5월 28일
hi gays
i use GA for extract best chrommosom in ALEXNET datastore and use SVM for classification and this my code
options = gaoptimset('CreationFcn', {@PopFunction},...
'PopulationSize',50,...
'Generations',GeLength,...
'PopulationType', 'bitstring',...
'SelectionFcn',{@selectiontournament,tournamentSize},...
'MutationFcn',{@mutationuniform, 0.1},...
'CrossoverFcn', {@crossoverarithmetic,0.8},...
'EliteCount',2,...
'StallGenLimit',100,...
'PlotFcns',{@gaplotbestf},...
'Display', 'iter');
nVars = GenomeLength;
FitnessFcn = @FitFunc_SVM;
[chromosome,~,~,~,~,~] = ga(FitnessFcn,nVars,options);
Best_chromosome = chromosome; % Best Chromosome
Feat_Index = find(Best_chromosome==1);
end
%%% POPULATION FUNCTION
function [pop] = PopFunction(GenomeLength,~,options)
RD = rand;
pop = (rand(options.PopulationSize, GenomeLength)> RD); % Initial Population
end
%%% FITNESS FUNCTION You may design your own fitness function here
function [FitVal] = FitFunc_SVM(pop)
global Data GenomeLength label_images
FeatIndex = find(pop==1); %Feature Index
X1 = Data;% Features Set
Y1 = grp2idx(label_images);% Class Information
X1 = X1(:,[FeatIndex]);
NumFeat = numel(FeatIndex);
but it give me error
Index in position 2 exceeds array bounds (must not exceed 4096).
Error in Genetic_Fit_Func>FitFunc_SVM (line 41)
X1 = X1(:,[FeatIndex]);
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11)
fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in makeState (line 47)
firstMemberScore = FitnessFcn(state.Population(initScoreProvided+1,:));
Error in gaunc (line 40)
state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ga (line 398)
[x,fval,exitFlag,output,population,scores] = gaunc(FitnessFcn,nvars, ...
Error in Genetic_Fit_Func (line 25)
[chromosome,~,~,~,~,~] = ga(FitnessFcn,nVars,options);
Can any one help me please?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by