Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to resolve this error when using amen_cross? #57

Open
honglizhaobob opened this issue Jun 21, 2021 · 6 comments
Open

How to resolve this error when using amen_cross? #57

honglizhaobob opened this issue Jun 21, 2021 · 6 comments

Comments

@honglizhaobob
Copy link

Hi, I usually get this error when I use amen_cross to approximate a function, especially when the dimension is large. Could you shed some lights on what the cause of this error might be?

"""
Error using amen_cross (line 369)
The initial solution is exactly zero. Try a better initial guess\n
"""

@dolgov
Copy link
Collaborator

dolgov commented Jun 22, 2021

All tensor elements sampled in the first iteration are zeros, so there is no information to proceed except assuming the entire tensor is zero. This may be true, but more likely the tensor contains undiscovered nonzero elements elsewhere, hence the error to warn the user. If you have any information about locations of nonzeros (e.g. a maximum of log(tensor) estimated otherwise), you can supply a tt_unit tensor (or a sum thereof) in the initial guess 'y0' parameter.

@honglizhaobob
Copy link
Author

Thanks a lot!

@honglizhaobob
Copy link
Author

Hi,

I was wondering if there are any suggestions for the cases where the multivariate function we are approximating has very small values (to the point of underflow).

For instance, if I would like to approximate a PDF in the Boltzmann form exp(-beta * energy), often times the values are very close to zero, which would lead to amen_cross throwing an error saying initial solution is exactly zero or giving a tensor with very low ranks such that the complexity of the function is not captured.

@dolgov
Copy link
Collaborator

dolgov commented Jul 13, 2021

If you can first approximate the energy tensor in TT, you can estimate its average or max, and subtract them. If that's not possible (e.g. energy contains exact Inf), you can approximate a tempered PDF and estimate its maximum, from which you can derive an estimate of max(energy) for the subtraction in the computation with the actual beta.

@honglizhaobob
Copy link
Author

Thanks Professor Dolgov,

I was able to compute an energy tensor and obtained an estimate of the average which is on the order of 1e+72. amen_cross takes in a function handle, I realize if I include the subtraction in the function handle, amen_cross_s will become very slow and cannot yield a result. Would there be other alternatives?

@dolgov
Copy link
Collaborator

dolgov commented Jul 16, 2021

"the average" of what? If it's the average of energy that is as large as 1e72, this might be hopeless anyway. What would exp(-1e72) be?
"if I include the subtraction in the function handle" - yes, a function @(energy)exp(-beta*(energy-const)) should work.
"amen_cross_s will become very slow" - why? The elementwise function cannot become much slower due to a single subtraction. If the new function produces larger TT ranks - that's normal, since now there is more nonzero elements in the tensor which have some nontrivial structure.
"cannot yield a result" - ??? Any details? In principle, maxvol2 can stuck in an infinite iteration if there are Inf or NaN elements. For example, if there is exp(1e72) appearing at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants