MATLAB Answers

Genetic algorithm in convolution nueral network

2 views (last 30 days)
asmaa hekal
asmaa hekal on 25 Apr 2019
Commented: souhila mehellou on 28 May 2019
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},...
'PopulationType', 'bitstring',...
'MutationFcn',{@mutationuniform, 0.1},...
'CrossoverFcn', {@crossoverarithmetic,0.8},...
'Display', 'iter');
nVars = GenomeLength;
FitnessFcn = @FitFunc_SVM;
[chromosome,~,~,~,~,~] = ga(FitnessFcn,nVars,options);
Best_chromosome = chromosome; % Best Chromosome
Feat_Index = find(Best_chromosome==1);
function [pop] = PopFunction(GenomeLength,~,options)
RD = rand;
pop = (rand(options.PopulationSize, GenomeLength)> RD); % Initial Population
%%% 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?

  1 Comment

Sign in to comment.

Answers (0)

Sign in to answer this question.