@@ -444,7 +444,7 @@ def nonlinear_eigenspace(L, k, alpha=1):
444
444
import pymanopt
445
445
from pymanopt import Problem
446
446
from pymanopt .manifolds import Grassmann
447
- from pymanopt .solvers import TrustRegions
447
+ from pymanopt .optimizers import TrustRegions
448
448
449
449
n = L .shape [0 ]
450
450
assert L .shape [1 ] == n , 'L must be square.'
@@ -454,26 +454,26 @@ def nonlinear_eigenspace(L, k, alpha=1):
454
454
manifold ._dimension = 1 # hack
455
455
456
456
# A solver that involves the hessian (check if correct TODO)
457
- solver = TrustRegions ()
457
+ solver = TrustRegions (verbosity = 0 )
458
458
459
459
# Cost function evaluation
460
- @pymanopt .function .Callable
460
+ @pymanopt .function .numpy ( manifold )
461
461
def cost (X ):
462
462
rhoX = np .sum (X ** 2 , 1 , keepdims = True ) # diag(X*X')
463
463
val = 0.5 * np .trace (X .T @ (L * X )) + \
464
464
(alpha / 4 ) * (rhoX .T @ mldivide (L , rhoX ))
465
465
return val
466
466
467
467
# Euclidean gradient evaluation
468
- @pymanopt .function .Callable
468
+ @pymanopt .function .numpy ( manifold )
469
469
def egrad (X ):
470
470
rhoX = np .sum (X ** 2 , 1 , keepdims = True ) # diag(X*X')
471
471
g = L @ X + alpha * np .diagflat (mldivide (L , rhoX )) @ X
472
472
return g
473
473
474
474
# Euclidean Hessian evaluation
475
475
# Note: Manopt automatically converts it to the Riemannian counterpart.
476
- @pymanopt .function .Callable
476
+ @pymanopt .function .numpy ( manifold )
477
477
def ehess (X , U ):
478
478
rhoX = np .sum (X ** 2 , 1 , keepdims = True ) # np.diag(X * X')
479
479
rhoXdot = 2 * np .sum (X .dot (U ), 1 )
@@ -493,8 +493,8 @@ def ehess(X, U):
493
493
# Call manoptsolve to automatically call an appropriate solver.
494
494
# Note: it calls the trust regions solver as we have all the required
495
495
# ingredients, namely, gradient and Hessian, information.
496
- problem = Problem (manifold = manifold , cost = cost , egrad = egrad , ehess = ehess ,
497
- verbosity = 0 )
498
- Xsol = solver .solve (problem , U0 )
496
+ problem = Problem (manifold = manifold , cost = cost , euclidean_gradient = egrad ,
497
+ euclidean_hessian = ehess )
498
+ Xsol = solver .run (problem , initial_point = U0 )
499
499
500
- return S0 , Xsol
500
+ return S0 , Xsol . point
0 commit comments