首页 > 其他 > 详细

MATLAB 损失函数画图

时间:2016-01-13 15:48:51      阅读:1034      评论:0      收藏:0      [点我收藏+]

损失函数画图

  • Hinge loss function:

\[H(z) = max(0,1-z)\]

  • $\psi$-learning loss function: 

\[{\phi _s}(z) = \left\{ {\begin{array}{*{20}{c}}
s&{z < 0}\\
0&{z \ge 0}
\end{array}} \right.\]

  • Normalized Sigmoid loss:

\[{P_t}(z) = 1 - \tanh (tz)\]

  • Ramp loss function:

\[{R_s}(z) = \left\{ {\begin{array}{*{20}{c}}
0&{z > 0}\\
{1 - z}&{0 \le z \le 1}\\
{1 - s}&{z > 1}
\end{array}} \right.\]

技术分享

 

%plot loss function

%define the loss function
H = @(z)max(0,1-z) ; %Hinge loss function
P = @(z)(2*(z<0)+0*(z>=0)); %\psi-learning loss function
S = @(z)(1-tanh(2*z)); %Normalized Sigmoid loss function
R = @(z)(1*(z<0)+(1-z).*(z>=0&z<1)+0*(z>=1)); % ramp loss

z=-2:0.01:2;
subplot(1,4,1) % plot the 1st figure of 1-4
plot(z,H(z),‘-‘,‘linewidth‘,2);
xlabel(‘z‘);
title(‘Hinge loss‘,‘fontweight‘,‘normal‘,‘fontsize‘,10);
axis([-2,2 0 3])

subplot(1,4,2)
plot(z,P(z),‘g-‘,‘linewidth‘,2);
xlabel(‘z‘);
title(‘\psi-learnig loss‘,‘fontweight‘,‘normal‘,‘fontsize‘,10);
axis([-2,2 0 3])

subplot(1,4,3)
plot(z,S(z),‘r-‘,‘linewidth‘,2);
xlabel(‘z‘);
title(‘Normalized Sigmoid loss‘,‘fontweight‘,‘normal‘,‘fontsize‘,10);
axis([-2,2 0 3])

subplot(1,4,4)
plot(z,R(z),‘b-‘,‘linewidth‘,2);
xlabel(‘z‘);
title(‘Ramp loss‘,‘fontweight‘,‘normal‘,‘fontsize‘,10);
axis([-2,2 0 3])

  

MATLAB 损失函数画图

原文:http://www.cnblogs.com/huadongw/p/5127186.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!