13 views

### Jason Brown

Jul 28, 2021, 12:55:21 PMJul 28
to Manopt
Hello.

I am trying to use pymanopt to minimize an infinity norm linear algebra problem. I am paraphrasing some code but essentially I generate some matrix R and want my problem setup to be

import pymanopt

manifold = Sphere(500)

def cost(X): return ag.linalg.norm(R @ X, ord=np.inf)

problem = Problem(manifold=manifold, cost=cost)

solver = SteepestDescent()

Xopt = solver.solve(problem)

Running any code with the ord = np.inf immediately gives a nan for the first gradient and there is clearly no convergence. I am unsure if this is a user error or rather an error with autograd, but it works as intended for ord = 2 and ag.sum(). I have tried installing tensorflow but I suspect it may be interfering with my packages as after installing all the ones I need, I am unable to install Spyder to actually run the code. Theano also gave an error as it seems it is not compatible with Python 3.9 from the error message.

Any help would be appreciated as I would think the infinity norm would be a rather standard for cost functions yet I seem unable to reach any convergence.

Thanks -

### Jason Brown

Jul 28, 2021, 1:19:18 PMJul 28
to Manopt
To be more specific, the following code works when ord = 2, but breaks when ord = np.inf and I do not understand why.

from pymanopt.manifolds import Sphere
from pymanopt.manifolds import Euclidean
from pymanopt import Problem
from pymanopt.solvers import SteepestDescent
import numpy.random as random
import numpy as np

R = random.randn(10,10)

manifold = Euclidean(R.shape)

def cost(X): return ag.linalg.norm( R @ X, ord = 2)

problem = Problem(manifold=manifold, cost=cost)

solver = SteepestDescent()

# let Pymanopt do the rest
Xopt = solver.solve(problem)

### Jason Brown

Jul 28, 2021, 5:47:16 PMJul 28
to Manopt
Update: I believe I'm able to workaround this by simply using ag.amax( ag.abs( R @ X)), but I will leave the question up because it might help for others or for future use.

### Nicolas Boumal

Aug 11, 2021, 3:01:38 AMAug 11
to Manopt
Hello,

As both the 2-norm and in infinity-norm are nondifferentiable at some points, it's not unreasonable that automatic differentiation behaves erratically. This cannot be truly fixed, except by smoothing the norms (e.g., soft-max for the infinity norm).

Glad to hear that your workaround mostly does the trick! After all, the norm is differentiable almost everywhere, so it does make sense that the computation would go through most of the time, depending on how the computations are arranged.

Best,
Nicolas