📄 opt_alpha_sigma.m
字号:
function [my_alpha_opt,my_sigma_opt,my_num_classes_opt] = Opt_Alpha_Sigma(dst,lrn_par,dim,n)%% Clustering Through Ranking On Manifolds% Version 0.2%% Copyright by Markus Breitenbach and Gregory Z. Grudic% This code is for your personal and research use only.%% http://www.cs.colorado.edu/~grudic/% http://ucsu.colorado.edu/~breitenm/%% This software is provided "as is," without warranty of any kind, express% or implied. In no event shall the authors be held liable% for any direct, indirect, incidental, special or consequential damages% arising out of the use of or inability to use this software.%for class_ind = 1:length(lrn_par.Cluster_Search) num_classes = lrn_par.Cluster_Search(class_ind); SIGMA_ONLY = 1; cost = []; my_sigma = lrn_par.OPT_SIGMA_MIN_INTERVEL:lrn_par.OPT_SIGMA_DEL_INTERVEL:lrn_par.OPT_SIGMA_MAX_INTERVEL; for i = 1:length(my_sigma) cost(i) = cost_alpha_sigma(my_sigma(i),dst,num_classes,n,SIGMA_ONLY,dim,lrn_par); indt = find(cost~=1000); if length(indt) > 2 os_min = my_sigma(i); if cost(i-1) < cost(i-2) & cost(i-1) < cost(i) % find dip %plot(my_sigma(cost~=1000),cost(cost~=1000)) options = optimset('Display','iter','MaxFunEvals',lrn_par.SIGMA_MaxFunEvals); %[x,fval] = fminbnd(@cost_alpha_sigma,my_sigma(i-2),my_sigma(i),options,dst,num_classes,n,SIGMA_ONLY,dim,lrn_par); [x,fval] = fminbnd('cost_alpha_sigma',my_sigma(i-2),my_sigma(i),options,dst,num_classes,n,SIGMA_ONLY,dim,lrn_par); break; elseif cost(i-1) < cost(i) %plot(my_sigma(cost~=1000),cost(cost~=1000)) %options = optimset('Display','iter','TolFun',1e-8,'MaxIter',10); options = optimset('Display','iter','MaxIter',lrn_par.OPT_ITER_INIT_SIGMA); %[x,fval] = fminbnd(@cost_alpha_sigma,my_sigma(i-3),my_sigma(i),options,dst,num_classes,n,SIGMA_ONLY,dim,lrn_par); [x,fval] = fminbnd('cost_alpha_sigma',my_sigma(i-3),my_sigma(i),options,dst,num_classes,n,SIGMA_ONLY,dim,lrn_par); break; end end t5555 = 0; end % debug x_s = x; fval_s = fval; my_alpha = lrn_par.my_alpha; if my_alpha <= 0 my_alpha = 0.99; end if lrn_par.OPT_S_A == 1 x_t = zeros(2,1); x_t(1,1) = x; x_t(2,1) = my_alpha; options = optimset('Display','iter','MaxFunEvals',lrn_par.SIGMA_ALPHA_MaxFunEvals,'LargeScale','off'); lb = zeros(size(x_t)); lb(1,1) = lrn_par.OPT_SIGMA_MIN_INTERVEL; lb(2,1) = 1e-8; ub = zeros(size(x_t)); ub(1,1) = lrn_par.OPT_SIGMA_MAX_INTERVEL; ub(2,1) = 1-(1e-8); SIGMA_ONLY = 0; %[x,fval] = fmincon(@cost_alpha_sigma,x_t,[],[],[],[],lb,ub,[],options,dst,num_classes,n,SIGMA_ONLY,dim,lrn_par); [x,fval] = fmincon('cost_alpha_sigma',x_t,[],[],[],[],lb,ub,[],options,dst,num_classes,n,SIGMA_ONLY,dim,lrn_par); tmp_my_alpha_opt(class_ind) = x(2); end opt_val(class_ind) = fval; tmp_o_sigma(class_ind)= sqrt(dim*x(1)^2); % debug [tst_x,tst_clus_close] = cost_alpha_sigma(x,dst,num_classes,n,SIGMA_ONLY,dim,lrn_par); t77 = 1;endind_best = find(opt_val == min(opt_val));if lrn_par.OPT_S_A == 1 my_alpha_opt = tmp_my_alpha_opt(ind_best);else my_alpha_opt = 0.99;endmy_sigma_opt = tmp_o_sigma(ind_best);my_num_classes_opt = lrn_par.Cluster_Search(ind_best);t77 = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -