Stability matrix inversion #81
Replies: 3 comments 1 reply
-
Hi, please stop scratching your head :) That is probably happening in eigen-decomposition. This functionality was implemented in the past but for some reason I deleted it. BTW, can you share your experiment code that made trouble? |
Beta Was this translation helpful? Give feedback.
-
For each backend, there is def meeinv(x, use_pinv=False):
try:
if use_pinv:
res = torch.linalg.pinv(x)
else:
res = torch.linalg.inv(x)
except torch._C._LinAlgError as e:
import logging
logging.basicConfig(
format='%(asctime)s; %(pathname)s; %(levelname)s:%(message)s',
level=logging.WARNING,
datefmt='%Y/%m/%d %H:%M:%S',
)
logging.warning('Matrix inversion failed in meeinv(). Adding perturbation.')
x += torch.eye(len(x)) * 1E-20
if use_pinv:
res = torch.linalg.pinv(x)
else:
res = torch.linalg.inv(x)
return res |
Beta Was this translation helpful? Give feedback.
-
Thank you a lot! I cannot share this code in particular (the seed of the optimization is a homemade metasurface) but I'll when I can (problem during a seedless optimization). Thank you again! |
Beta Was this translation helpful? Give feedback.
-
Hi, i am scratching my head over an error in meent, I am trying to optimize a metasurface and I usually get the error " The algorithm failed to converge because the input matrix is ill-conditioned". I am not sure but I believe it happens more using vectorial shapes. I have seen the p_inv and perturbation options. I am not sure what this perturbation is about, is it like Tikhonov regularization or is it linked with the Enhanced transmission matrix approch discussed in your paper?
I suppose you get this error time to time, how do you proceed to solve it?
Right now I would proceed like this:
Thank you in advance ~
Beta Was this translation helpful? Give feedback.
All reactions