Mercurial > hg > camir-ismir2012
annotate toolboxes/distance_learning/mlr/loss/lossHinge.m @ 0:cc4b1211e677 tip
initial commit to HG from
Changeset:
646 (e263d8a21543) added further path and more save "camirversion.m"
author | Daniel Wolff |
---|---|
date | Fri, 19 Aug 2016 13:07:06 +0200 |
parents | |
children |
rev | line source |
---|---|
Daniel@0 | 1 function Xi = lossHinge(W, Psi, M, gradient) |
Daniel@0 | 2 % |
Daniel@0 | 3 % Xi = lossHinge(W, Psi, M, gradient) |
Daniel@0 | 4 % |
Daniel@0 | 5 % W: d*d metric |
Daniel@0 | 6 % Psi: d*d feature matrix |
Daniel@0 | 7 % M: the desired margin |
Daniel@0 | 8 % gradient: if 0, returns the loss value |
Daniel@0 | 9 % if 1, returns the gradient of the loss WRT W |
Daniel@0 | 10 |
Daniel@0 | 11 Xi = max(0, M - sum(sum(W .* Psi))); |
Daniel@0 | 12 |
Daniel@0 | 13 if gradient & Xi > 0 |
Daniel@0 | 14 Xi = -Psi; |
Daniel@0 | 15 end |
Daniel@0 | 16 end |