繁体   English   中英

如何检查成本函数是凹面还是凸面?

[英]How do i check if a cost function is Concave or Convex?

自组织地图成本函数

如何检查此成本函数是凹面还是凸面? 我还想查找它是否具有一个或多个最小值。

努力;

   function [w,pi,costvalue] = main_cost(inputdata, tmax,   alpha_ini,somrow,somcol)
   %main cost function; To get cost value for all possible random weights
   %Input:
   %inputdata : Data sample
   %tmax : Maximum Iteraitions - This determines the number of generated
   %random w and pi with cost function computation for each set. 
   %alpha_ini : The learning rate
   %Somrow,somcol : map size 

   %Output
   %w: Som weights 
   %pi: Global weights
   %costvalue: cost for a set of w,pi and input data

   %Example
   %load expdata_normalized;
   %[w,pi,costvalue]=main_cost(expdata_normalized,500,0.1,5,5);

   N = somrow * somcol; %all neurons
   Dimension = size(inputdata,2);%input data dimension
   % Get the corresponding 2D locations of the N neurons on the map
  [u(:,1) u(:,2)] = ind2sub([somrow somcol], 1:N);
  alpha = alpha_ini; %set initial learning rate

  %set map effective width
  sigma_ini = 2;
  sigma = sigma_ini;


  %initialise costvalues
  costval=zeros(1,tmax);

  %for 1 to max iterations
  for t = 1:tmax
  tic
 %generate random SOM weights
 w{t} = round(rand(N,Dimension),1);
 %generate random Global weights
 pi{t} = round (rand(1,Dimension),1);

% For 1 to all samples in the data
for j = 1:size(inputdata,1) 
   % Pick a single sample
    samplei = inputdata(j,:);
   % make global weight same dimension with SOM weights
    pirepmat = repmat(pi{t},N,1);
    % determine the winning node, from weights at iter(t) to picked
    % sample
    bmu = part1_closestNeuron(samplei, w{t},1,pirepmat);
    % calculate neighbourhood for SOM at iter (t)
    for k = 1:size(w{t},1)
        neighbourhoodF = exp(-eucdist(u(bmu,:),u(k,:), somrow, somcol, 1)^2 / (2*sigma^2));
        allneighbourhoodF(k)= neighbourhoodF;
    end
    % now get cost value with; inputdata(all-static), Somweights at
    % iter(t), and Global weights at iter(t)
    costval(t) = costval(t)+CostFunction_iter(inputdata, w{t},pi{t},allneighbourhoodF);
end
toc
end
costvalue = costval;
end

我在上面的代码中尝试做的是获取一个随机权重值作为上述成本函数的输入,然后使用一个不变的样本计算这些随机输入的成本值,如果我发现多个最小成本,则确认我的成本函数不是凸的。

我的代码与我在问题中发布的成本函数略有不同,因为我还有其他输入。 作为我的实现的输出,我拥有针对我的样本的不同权重的成本值,现在我很难形象化这一点。

您需要了解什么是凸度。 对于简短版本, 请查看Wikipedia

有关更详细的版本,我建议博伊德关于凸优化的课程的第2课和第3课。 该课程的开始部分介绍了许多用于识别/检查凸度的有用数学。

如果函数不是凸的,则可以通过找到反例来反证凸:

  • 如果是2d或3d,则绘制函数图。
  • 绘制应用于两个随机点的凸组合的函数值,并查找非凸区域。

如果在[0,1]存在两个点xy以及标量a ,那么a * f(x) + (1-a) * f(y) < f(a*x +(1-a) * y) (基本上是向下曲线的某处)。

未能证明凸度与证明凸度一样! 一些证明凸性的方法是:

  • 显示Hessian是正半定的。
  • 直接应用凸度的定义(显示定义满足所有可能性)
  • 根据构造规则表明函数是凸的。 一组凸函数的逐点最大值是凸的。 等...应用这样的定理。

看一眼发布的图像,规范总是凸出的(定义的后果)。 凸函数之和是凸的,但我不知道K是什么...

您不能通过仿真检查。

凸性是您需要通过查看成本函数的导数在纸上检查的属性。 严格地,这需要数学解决,而不是用matlab实例仿真解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM