From 3969b18189dfe048fab922cff95e48507deae3cc Mon Sep 17 00:00:00 2001 From: Davis King Date: Thu, 13 May 2010 01:24:16 +0000 Subject: [PATCH] Changed the code so that the manifold regularizer is normalized by the number of edges involved in its creation. --HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403598 --- .../linear_manifold_regularizer.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dlib/manifold_regularization/linear_manifold_regularizer.h b/dlib/manifold_regularization/linear_manifold_regularizer.h index 1ac163ce1..abf5804ad 100644 --- a/dlib/manifold_regularization/linear_manifold_regularizer.h +++ b/dlib/manifold_regularization/linear_manifold_regularizer.h @@ -195,6 +195,8 @@ namespace dlib impl::undirected_adjacency_list graph; graph.build(edges, weight_funct); + num_edges = edges.size(); + make_mr_matrix(samples, graph); } @@ -208,8 +210,13 @@ namespace dlib if (dimensionality() == 0) return general_matrix(); - // TODO: should we divide intrinsic_regularization_strength by the number of edges? That maybe a more - // reasonable interface. + + // This isn't how it's defined in the referenced paper but normalizing these kinds of + // sums is typical of most machine learning algorithms. Moreover, doing this makes + // the argument to this function more invariant to the size of the edge set. So it + // should make it easier for the user. + intrinsic_regularization_strength /= num_edges; + return inv_lower_triangular(chol(identity_matrix(reg_mat.nr()) + intrinsic_regularization_strength*reg_mat)); } @@ -269,6 +276,7 @@ namespace dlib } general_matrix reg_mat; + unsigned long num_edges; }; }