@@ -444,7 +444,7 @@ def nonlinear_eigenspace(L, k, alpha=1):
444444 import pymanopt
445445 from pymanopt import Problem
446446 from pymanopt .manifolds import Grassmann
447- from pymanopt .solvers import TrustRegions
447+ from pymanopt .optimizers import TrustRegions
448448
449449 n = L .shape [0 ]
450450 assert L .shape [1 ] == n , 'L must be square.'
@@ -454,26 +454,26 @@ def nonlinear_eigenspace(L, k, alpha=1):
454454 manifold ._dimension = 1 # hack
455455
456456 # A solver that involves the hessian (check if correct TODO)
457- solver = TrustRegions ()
457+ solver = TrustRegions (verbosity = 0 )
458458
459459 # Cost function evaluation
460- @pymanopt .function .Callable
460+ @pymanopt .function .numpy ( manifold )
461461 def cost (X ):
462462 rhoX = np .sum (X ** 2 , 1 , keepdims = True ) # diag(X*X')
463463 val = 0.5 * np .trace (X .T @ (L * X )) + \
464464 (alpha / 4 ) * (rhoX .T @ mldivide (L , rhoX ))
465465 return val
466466
467467 # Euclidean gradient evaluation
468- @pymanopt .function .Callable
468+ @pymanopt .function .numpy ( manifold )
469469 def egrad (X ):
470470 rhoX = np .sum (X ** 2 , 1 , keepdims = True ) # diag(X*X')
471471 g = L @ X + alpha * np .diagflat (mldivide (L , rhoX )) @ X
472472 return g
473473
474474 # Euclidean Hessian evaluation
475475 # Note: Manopt automatically converts it to the Riemannian counterpart.
476- @pymanopt .function .Callable
476+ @pymanopt .function .numpy ( manifold )
477477 def ehess (X , U ):
478478 rhoX = np .sum (X ** 2 , 1 , keepdims = True ) # np.diag(X * X')
479479 rhoXdot = 2 * np .sum (X .dot (U ), 1 )
@@ -493,8 +493,8 @@ def ehess(X, U):
493493 # Call manoptsolve to automatically call an appropriate solver.
494494 # Note: it calls the trust regions solver as we have all the required
495495 # 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 )
499499
500- return S0 , Xsol
500+ return S0 , Xsol . point
0 commit comments