loss_lrd - conjugate logistic loss function Syntax: [floss, gloss, hloss, hmin]=loss_lrd(aa, yy) Copyright(c) 2009 Ryota Tomioka This software is distributed under the MIT license. See license.txt
0001 % loss_lrd - conjugate logistic loss function 0002 % 0003 % Syntax: 0004 % [floss, gloss, hloss, hmin]=loss_lrd(aa, yy) 0005 % 0006 % Copyright(c) 2009 Ryota Tomioka 0007 % This software is distributed under the MIT license. See license.txt 0008 function varargout = loss_lrd(aa, yy) 0009 0010 mm=length(aa); 0011 0012 gloss=nan*ones(mm,1); 0013 0014 ya = aa.*yy; 0015 0016 I = find(0<ya & ya<1); 0017 0018 0019 floss = sum((1-ya(I)).*log(1-ya(I))+ya(I).*log(ya(I))); 0020 gloss(I) = yy(I).*log(ya(I)./(1-ya(I))); 0021 0022 hmin = 4; 0023 0024 if nargout<=3 0025 varargout={floss, gloss, hmin}; 0026 else 0027 hloss = spdiag(1./(ya.*(1-ya))); 0028 varargout={floss, gloss, hloss, hmin}; 0029 end 0030 0031