Mercurial > hg > camir-aes2014
annotate toolboxes/distance_learning/mlr/loss/lossHingeDiagMKL.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
rev | line source |
---|---|
wolffd@0 | 1 function Xi = lossHingeDiagMKL(W, Psi, M, gradient) |
wolffd@0 | 2 % |
wolffd@0 | 3 % Xi = lossHingeDiagMKL(W, Psi, M, gradient) |
wolffd@0 | 4 % |
wolffd@0 | 5 % W: d*m matrix of diagonal metrics |
wolffd@0 | 6 % Psi: d*m feature matrix |
wolffd@0 | 7 % M: the desired margin |
wolffd@0 | 8 % gradient: if 0, returns the loss value |
wolffd@0 | 9 % if 1, returns the gradient of the loss WRT W |
wolffd@0 | 10 |
wolffd@0 | 11 Xi = max(0, M - trace(W' * Psi)); |
wolffd@0 | 12 |
wolffd@0 | 13 if gradient & Xi > 0 |
wolffd@0 | 14 Xi = -Psi; |
wolffd@0 | 15 end |
wolffd@0 | 16 end |