-
Notifications
You must be signed in to change notification settings - Fork 175
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
SO3_fft_real and SO3_ifft_real do not seem to be inverses of each other? #43
Comments
A random signal contains a lot of high frequencies but these high frequencies cannot be preserved by the transformation. |
Hi Mario Thanks for the reply, you were exactly right. Redoing the experiment with x_hat does show that the transformations are invertible. (I also found that if I start with a signal x with zeros everywhere except one location where it is 1.0, the same problems persist, again explained by the fact that there are too many high frequencies.) However, I obviously do not observe these with when these signals are defined on the real line (rather than the sphere) and I use the usual 1D FFT and 1D IFFT. I was wondering if you think it is this particular implementation of the FFT on SO(3) that leads to this behavior. Another thing I noticed which I think may be related to the same problem and could be useful to others as well. (I can post it as a separate issue if you think it is a different topic.) I took a spherical MNIST image using gen_data.py, x. I created x_hat using S2_fft_real() followed by S2_ifft_real() so as to avoid any problems with the high frequencies. (x_hat is actually quite close to x). Then I computed the spherical auto-correlation using x_hat_fft = s2_fft_real.apply(x_hat, 10) However, when I look at auto_corr, there seem to be some issues:
I also tried to correlate x_hat with a Dirac function at 0,0 defined on the sphere. Again, the spherical correlation results are not interpretable as far as I can see. This has stumped me and I am hoping for some resolution. Thank you so much again for the great support even now after such a long time since publication |
It should work... and you share the code please? |
This is the test code I am using. For the particular image I am testing I get torch.norm(imagehat)**2 = 241.2491 and auto_corr[0,0,0,0,0] = 0.0377. As an aside, [0,0,0] is indeed very close to where auto_corr attains its maximum. import numpy as np
import torch
import torch.nn as nn
from s2cnn import SO3Convolution
from s2cnn import S2Convolution
from s2cnn import so3_integrate
from s2cnn import so3_near_identity_grid
from s2cnn import s2_near_identity_grid
from s2cnn.soft.s2_fft import S2_fft_real, S2_ifft_real
from s2cnn.soft.so3_fft import SO3_fft_real, SO3_ifft_real
from s2cnn.s2_mm import s2_mm
import gzip
import pickle
import ipdb
import scipy.io
MNIST_PATH = "s2_mnist_train_nr_test_nr.gz"
with gzip.open(MNIST_PATH, 'rb') as f:
dataset = pickle.load(f)
train_data = torch.from_numpy(dataset["train"]["images"][:, None, :, :].astype(np.float32))
### Get one image for testing and convert to batched version
image = train_data[0,0,:,:].unsqueeze(0).unsqueeze(0)
image = image/255.0
### Removing high frequencies if any (following what Mario Geiger suggested on Github)
image_fft = S2_fft_real.apply(image)
imagehat = S2_ifft_real.apply(image_fft)
### Try auto-correlation with the reconstructed image, auto_corr should be equal to torch.norm(imagehat)**2 at alpha = beta = gamma = 0.0, where it should also attain its maximum
imagehat_fft = S2_fft_real.apply(imagehat,10)
auto_corr_fft = s2_mm(imagehat_fft, imagehat_fft)
auto_corr = SO3_ifft_real.apply(auto_corr_fft)
print(torch.norm(imagehat)**2)
print(auto_corr[0,0,0,0,0])``` |
I don't have |
Also try to compute |
Another think, you asked why Fourier transform are exact on the plane but not on the sphere. I think it's because there are no regular tiling of the sphere. |
Hi Mario Thanks for the suggestions.
Nothing else I do has helped so far. Thank you again |
It would also be great if you could point me to a clear formula for what The equivariance plots provided in the repository, provided as an example, suggest that everything should work as expected. Just not the code I am trying to run, which is really weird. |
https://github.com/jonas-koehler/s2cnn/blob/master/s2cnn/s2_mm.py#L30-L58 in pseudo code, it does the following
|
"However, I obviously do not observe these with when these signals are defined on the real line (rather than the sphere) and I use the usual 1D FFT and 1D IFFT. I was wondering if you think it is this particular implementation of the FFT on SO(3) that leads to this behavior." "At alpha = beta = gamma = 0, the value of the auto_corr should be equal to the square of the L2 norm of x_hat (right?). However, the values are 4 orders of magnitude smaller and it is not a constant scale factor that applies to different runs using different x_hat's." "It would also be great if you could point me to a clear formula for what s2_mm is accomplishing." |
Hi Taco Thank you very much for these clarifications. Yes, s2_mm is bilinear, and both S2_fft and SO3_ifft are linear. I did try to play with the normalization factors a little, but could not get it to work. It appears that for the FFT functions, S3.quadrature weights are multiplied to the Wigner matrices. For the IFFT functions, the Wigner d-matrices are multiplied by 2L+1. I tried removing these weights, but that does not help. I don't fully follow why these weights are present, I feel that is one possible reason why the results are not as expected. Suhas |
Hello
I did a simple experiment where I created a random signal x on SO(3) (I tried multiple bandwidths = 20,30,40). Then I computed the FFT using
x_fft = SO3_fft_real.apply(x)
Finally, I computed the IFFT using
x_hat = SO3_ifft_real.apply(x_fft)
I found that x and x_hat are very different from each other and appear to have no patterns that I can identify. For example, one is not a scaled version of the other.
Any help here is appreciated, It's possible I am just using the functions incorrectly.
Thanks
Suhas
The text was updated successfully, but these errors were encountered: