Home > manopt > manifolds > fixedrank > fixedrankfactory_2factors_preconditioned.m

fixedrankfactory_2factors_preconditioned

PURPOSE ^

Manifold of m-by-n matrices of rank k with two factor quotient geometry.

SYNOPSIS ^

function M = fixedrankfactory_2factors_preconditioned(m, n, k)

DESCRIPTION ^

 Manifold of m-by-n matrices of rank k with two factor quotient geometry.

 function M = fixedrankfactory_2factors_preconditioned(m, n, k)

 This geometry is tuned to least-squares problems such as low-rank matrix
 completion with ell-2 loss.

 A point X on the manifold is represented as a structure with two
 fields: L and R. The matrices L (m-by-k) and R (n-by-k) are 
 full column-rank matrices such that X = L*R'.

 Tangent vectors are represented as a structure with two fields: L, R.
 
 Please cite the Manopt paper as well as the research paper:
     @Techreport{mishra2012optimized,
       Title   = {A {R}iemannian geometry for low-rank matrix completion},
       Author  = {Mishra, B. and Adithya Apuroop, K. and Sepulchre, R.},
       Journal = {Arxiv preprint arXiv:1211.1550},
       Year    = {2012}
     }


 See also: fixedrankembeddedfactory fixedrankfactory_2factors fixedrankfactory_3factors_preconditioned

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function M = fixedrankfactory_2factors_preconditioned(m, n, k)
0002 % Manifold of m-by-n matrices of rank k with two factor quotient geometry.
0003 %
0004 % function M = fixedrankfactory_2factors_preconditioned(m, n, k)
0005 %
0006 % This geometry is tuned to least-squares problems such as low-rank matrix
0007 % completion with ell-2 loss.
0008 %
0009 % A point X on the manifold is represented as a structure with two
0010 % fields: L and R. The matrices L (m-by-k) and R (n-by-k) are
0011 % full column-rank matrices such that X = L*R'.
0012 %
0013 % Tangent vectors are represented as a structure with two fields: L, R.
0014 %
0015 % Please cite the Manopt paper as well as the research paper:
0016 %     @Techreport{mishra2012optimized,
0017 %       Title   = {A {R}iemannian geometry for low-rank matrix completion},
0018 %       Author  = {Mishra, B. and Adithya Apuroop, K. and Sepulchre, R.},
0019 %       Journal = {Arxiv preprint arXiv:1211.1550},
0020 %       Year    = {2012}
0021 %     }
0022 %
0023 %
0024 % See also: fixedrankembeddedfactory fixedrankfactory_2factors fixedrankfactory_3factors_preconditioned
0025 
0026 % This file is part of Manopt: www.manopt.org.
0027 % Original author: Bamdev Mishra, Dec. 30, 2012.
0028 % Contributors:
0029 % Change log:
0030 %
0031 %    April 04, 2015 (BM):
0032 %      Cosmetic changes including avoiding storing the inverse of a
0033 %       k-by-k matrix.
0034   
0035     
0036     M.name = @() sprintf('LR''(tuned to least square problems) quotient manifold of %dx%d matrices of rank %d', m, n, k);
0037     
0038     M.dim = @() (m+n-k)*k;
0039     
0040     
0041     % Some precomputations at the point X to be used in the inner product
0042     % (and pretty much everywhere else).
0043     function X = prepare(X)
0044         if ~all(isfield(X,{'LtL','RtR'}))
0045             L = X.L;
0046             R = X.R;
0047             X.LtL = L'*L;
0048             X.RtR = R'*R;
0049         end
0050     end
0051     
0052     
0053     % The choice of metric is motivated by symmetry and
0054     % tuned to least-squares cost function.
0055     M.inner = @iproduct;
0056     function ip = iproduct(X, eta, zeta)
0057         X = prepare(X);
0058         ip = trace(X.RtR*(eta.L'*zeta.L)) + trace(X.LtL*(eta.R'*zeta.R)); % Scaled metric
0059     end
0060     
0061     M.norm = @(X, eta) sqrt(M.inner(X, eta, eta));
0062     
0063     M.dist = @(x, y) error('fixedrankfactory_2factors_preconditioned.dist not implemented yet.');
0064     
0065     M.typicaldist = @() 10*k;
0066     
0067     M.egrad2rgrad = @egrad2rgrad;
0068     function rgrad = egrad2rgrad(X, egrad)
0069         X = prepare(X);
0070         
0071         % Riemannian gradient
0072         rgrad.L = egrad.L/X.RtR;
0073         rgrad.R = egrad.R/X.LtL;
0074     end
0075     
0076     M.ehess2rhess = @ehess2rhess;
0077     function Hess = ehess2rhess(X, egrad, ehess, eta)
0078         X = prepare(X);
0079         
0080         % Riemannian gradient.
0081         rgrad = egrad2rgrad(X, egrad);
0082         
0083         % Directional derivative of the Riemannian gradient.
0084         Hess.L = ehess.L/X.RtR - 2*egrad.L*(X.RtR \ (symm(eta.R'*X.R) / X.RtR));
0085         Hess.R = ehess.R/X.LtL - 2*egrad.R*(X.LtL \ (symm(eta.L'*X.L) / X.LtL));
0086         
0087         % We still need a correction factor for the non-constant metric.
0088         Hess.L = Hess.L + rgrad.L*(symm(eta.R'*X.R)/X.RtR) + eta.L*(symm(rgrad.R'*X.R)/X.RtR) - X.L*(symm(eta.R'*rgrad.R)/X.RtR);
0089         Hess.R = Hess.R + rgrad.R*(symm(eta.L'*X.L)/X.LtL) + eta.R*(symm(rgrad.L'*X.L)/X.LtL) - X.R*(symm(eta.L'*rgrad.L)/X.LtL);
0090         
0091         % Project on the horizontal space.
0092         Hess = M.proj(X, Hess);
0093     end
0094     
0095     M.proj = @projection;
0096     function etaproj = projection(X, eta)
0097         X = prepare(X);
0098         
0099         % Projection onto the horizontal space.
0100         Lambda = 0.5*((eta.R'*X.R)/X.RtR  -   X.LtL\(X.L'*eta.L));
0101         etaproj.L = eta.L + X.L*Lambda;
0102         etaproj.R = eta.R - X.R*Lambda';
0103     end
0104     
0105     M.tangent = M.proj;
0106     
0107     M.tangent2ambient = @(X, eta) eta;
0108     
0109     M.retr = @retraction;
0110     function Y = retraction(X, eta, t)
0111         if nargin < 3
0112             t = 1.0;
0113         end
0114         Y.L = X.L + t*eta.L;
0115         Y.R = X.R + t*eta.R;
0116         
0117         % Numerical conditioning step: a simpler version.
0118         % We need to ensure that L and R are do not have very relative
0119         % skewed norms.
0120         
0121         scaling = norm(X.L, 'fro')/norm(X.R, 'fro');
0122         scaling = sqrt(scaling);
0123         Y.L = Y.L / scaling;
0124         Y.R = Y.R * scaling;
0125         
0126         % These are reused in the computations of gradient and Hessian.
0127         Y = prepare(Y);
0128     end
0129     
0130     
0131     M.exp = @exponential;
0132     function Y = exponential(X, eta, t)
0133         if nargin < 3
0134             t = 1.0;
0135         end
0136         
0137         Y = retraction(X, eta, t);
0138         warning('manopt:fixedrankfactory_2factors_preconditioned:exp', ...
0139             ['Exponential for fixed rank ' ...
0140             'manifold not implemented yet. Used retraction instead.']);
0141     end
0142     
0143     M.hash = @(X) ['z' hashmd5([X.L(:) ; X.R(:)])];
0144     
0145     M.rand = @random;
0146     
0147     function X = random()
0148         X.L = randn(m, k);
0149         X.R = randn(n, k);
0150     end
0151     
0152     M.randvec = @randomvec;
0153     function eta = randomvec(X)
0154         eta.L = randn(m, k);
0155         eta.R = randn(n, k);
0156         eta = projection(X, eta);
0157         nrm = M.norm(X, eta);
0158         eta.L = eta.L / nrm;
0159         eta.R = eta.R / nrm;
0160     end
0161     
0162     M.lincomb = @lincomb;
0163     
0164     M.zerovec = @(X) struct('L', zeros(m, k),'R', zeros(n, k));
0165     
0166     M.transp = @(x1, x2, d) projection(x2, d);
0167     
0168     % vec and mat are not isometries, because of the scaled inner metric.
0169     M.vec = @(X, U) [U.L(:) ; U.R(:)];
0170     
0171     M.mat = @(X, u) struct('L', reshape(u(1:(m*k)), m, k), ...
0172         'R', reshape(u((m*k+1):end), n, k));
0173     
0174     M.vecmatareisometries = @() false;
0175     
0176     % Auxiliary functions
0177     symm = @(M) .5*(M+M');
0178 end
0179 
0180 % Linear combination of tangent vectors.
0181 function d = lincomb(x, a1, d1, a2, d2) %#ok<INUSL>
0182     
0183     if nargin == 3
0184         d.L = a1*d1.L;
0185         d.R = a1*d1.R;
0186     elseif nargin == 5
0187         d.L = a1*d1.L + a2*d2.L;
0188         d.R = a1*d1.R + a2*d2.R;
0189     else
0190         error('Bad use of fixedrankfactory_2factors_preconditioned.lincomb.');
0191     end
0192     
0193 end
0194 
0195 
0196 
0197 
0198

Generated on Fri 08-Sep-2017 12:43:19 by m2html © 2005