oseledets / TT-Toolbox

The git repository for the TT-Toolbox
Other
189 stars 73 forks source link

How to resolve this error when using ``amen_cross``? #57

Open honglizhaobob opened 3 years ago

honglizhaobob commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Thanks a lot!

honglizhaobob commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

"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.