Karhunen Loeve 2D random SVD algorithm

Hello everybody,

I am working with 2D images and I aim to perform a Karhunen-Loeve decomposition to reduce the dimension of my data. As my images do not have the same dimensions and meshes, I have performed interpolation on them to have a common mesh and flatten them to have 1D fields ready to be used with the SVD KL algorithm ( KarhunenLoeveSVDAlgorithm - OpenTURNS 1.19 documentation)

But the common mesh I use is quite thin, so the size of my dataset becomes large very quickly with the computation time that goes with it. I was recommended to use the ‘KarhunenLoeveSVDAlgorithm-UseRandomSVD’ flag to trigger the stochastic SVD algorithm use at the OT users’ days, but it does not seem to speed up the algorithm… Indeed, nothing really change when I look at computation times for the few tries i have done, it seems that the algorithm isn’t really triggered.

Is there something else I need to do to speed up the algorithm ?

Thaks in advance !


Something strange is happening here as you should see a speed-up. First of all, once you have interpolated your images on a common 2D mesh, you don’t need to flatten them to use the KarhunenLoveSVDalgorithm class: the algorithm works with meshes in any dimension. Could you give more details on the different sizes involved? I mean, the number of pixels in the interpolation mesh and the number of images. By default, KarhunenLoveSVDalgorithm computes the 1000 largest singular values (it can be changed using ot.ResourceMap.SetAsUnsignedInteger("KarhunenLoeveSVDAlgorithm-RandomSVDMaximumRank", 1000)) so if you have less than 1000 images you will not see any speedup.

You can check that the random SVD is used by increasing the log level: ot.Log.Show(ot.Log.INFO). You should see one line with Use random SVD.