Genetic algorithm in convolution nueral network

2 visualizzazioni (ultimi 30 giorni)
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?

Risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by