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

Regarding the Autoencoder model #12

Open
Wasim04 opened this issue Mar 25, 2024 · 12 comments
Open

Regarding the Autoencoder model #12

Wasim04 opened this issue Mar 25, 2024 · 12 comments

Comments

@Wasim04
Copy link

Wasim04 commented Mar 25, 2024

Hi,

This might not be the right place, but didn't find other contact options so posting it here.
It is regarding the autoencoder model in deepshphere tf2 tutorial. Using this tutorial, with a good amount of sample data, I am able to reconstruct a input healpy map with reasonably recovered features. However, instead of passing the training data in both x and y, if I try to pass a label dataset against the training dataset in y, in an attempt to denoising the map, I find that the model doesn't recover the desired features. I am wondering if there is any similar tutorial for denoising or if you have come across similar situation.

Many Thanks
Wasim

@jafluri
Copy link
Collaborator

jafluri commented Mar 26, 2024

Hello,

Thanks for your interest in deepsphere.

What noise levels (SNR) are you talking about? The standard graph layers in Deepsphere can struggle with high frquencies, so it might be good to interlace some Conv1D layers or go with a UNet + Skips architecture.

I might be able to brew together an example later this week.

Best,

Janis

@Wasim04
Copy link
Author

Wasim04 commented Mar 26, 2024

Hi Janis,

Thanks for your reply. So, due to the nature of my study, a 'true label' is not generally available. For training purpose, I tried with a set of training data with SNR 25, and created a 'true lable data' by amplifying signal information in the training data to SNR 45. I guess my exception was, that the model might be able to recover the loud features better and reduce/remove the rest while decoding. Thanks for the suggestion with UNet++ skip connection. I shall look into it. I hate to burden you like this in your busy schedule, but an example will be a tremendous help.

Many Thanks
Wasim

jafluri added a commit that referenced this issue Apr 1, 2024
@jafluri
Copy link
Collaborator

jafluri commented Apr 1, 2024

Dear Wasim

Sorry for the delay, I was a bit busier than expected.

I just pushed a new branch that contains a new example notebook with a denoising UNet (see commit 86d5e6d). I tested it with the same toy data and it seems to do what I'd expect.

As I mentioned earlier, it might be good to add some Conv1D layers to the blocks to increase the capacity of the model. So I'd recommend to use this example as a template and play around until you have an architecture that works for you.

Best,
Janis

@Wasim04
Copy link
Author

Wasim04 commented Apr 2, 2024

Hi Janis,

No no, I am really grateful for your help and that you made time for me during holidays. I am running this model now and I can see it is in the right direction for my expected outcome. I would try adjusting it with my requirements. Thank you so much for the tutorial.

Many Thanks
Wasim

@Wasim04
Copy link
Author

Wasim04 commented Jun 5, 2024

Hi Janis,
Sorry to bother you again. When you advised to include some Conv1D layers in the blocks, did you mean a general tf.keras Conv1D, as in tf.keras.layers.Conv1D(filters=Fout, kernel_size=3, padding='same', activation='elu') ? or HealpyPseudoConv(p=1, Fout=Fout, activation="elu") ? The reason I ask is that I was able to reconstruct my input map features adding extra tf.keras Conv1D layers, but some artefacts consistently appear on the predicted map. I was wondering if Conv1D is failing to respect the heapy data structure.
On the other hand, adding HealpyPseudoConv() seems to be complicating the operation further, where I am not being able to resolve the shape error.

Many Thanks
Wasim

@jafluri
Copy link
Collaborator

jafluri commented Jun 5, 2024

Hello,

Yes, I was referring to tf.keras.layers.Conv1D, HealpyPseudoConv only act on proper HealPix (super-)pixel and therefore, can't really change the structure in a consistent way. The standard tf.keras.layers.Conv1D can introduce artifact though as you observed. I would generally advise using them only when you have at least 32 channels and also longer kernel sizes, e.g. 9 or more. Have you tried this? What's the size of your maps?

Best,

Janis

@Wasim04
Copy link
Author

Wasim04 commented Jun 5, 2024

Hi Janis,
My map size is (1000, 49152). Two sets of data (noisy data and true data). I have tried with kernel sizes 3, 9 etc. I get reasonable reconstruction with kernel size 3 but artefacts contaminate it. I am not very sure about channels.

Many Thanks
Wasim

@jafluri
Copy link
Collaborator

jafluri commented Jun 8, 2024

Sorry for the late reply, I am currently travelling and have only limited internet access.

The channels are the number of filters that you use. You should make sure that you have enough such that the convolution has an adequate capacity. Finding the right architecture can be quite tricky and there are only heuristics that can help you. If you want, you can post your entire architecture and I might be able to give you some feedback.

Best,

Janis

@Wasim04
Copy link
Author

Wasim04 commented Jun 10, 2024

Hi Janis,
I can understand and I do apologise for bothering you in your busy schedule. I tried various permutations and combinations. Here is my architecture (attached), other than the serialisation attempt to allow the subclass model to save, there are only two conv1D layers that I tried to incorporate. I also wondered, in this model the fact that the 'Down Sampling'goes:
Step 1: nside 64 -> 32
Step 2: nside 32 -> 16
Step 3: nside 16 -> 8

The Upsampling goes as:
Step 1: nside 16 -> 32
Step 2: nside 32 -> 64
Step 3: nside 64 -> 128
My input maps are all nside 64. How this last transformation is being handled? in the upsampling loop where we put self.up_layers[1:], leaving the first layer. It goes to nside 128 to follow the same number of iterations as downsampling. I tried holding it up to 64. But couldn't, resolve the shape error.

Many Thanks
Wasim
HealpyUnet.txt

@jafluri
Copy link
Collaborator

jafluri commented Jun 22, 2024

Hi Wasim,

Again, sorry for the late reply and that I wasn't able to look at your code. I am now back from my trip and have more time. Let me know if you still have problems and I'll have a look.

@Wasim04
Copy link
Author

Wasim04 commented Jun 22, 2024

Hi Janis,
I completely understand. I haven’t been able to resolve the issue. Please have a look at the code attached at your convenience. I was wondering if you would be available for a short zoom meeting at some point in the coming days. I could show you my project and that might be easier for you to see what I have done wrong.

Many Thanks
Wasim

@jafluri
Copy link
Collaborator

jafluri commented Jun 24, 2024

Sure, that should be possible. You can find my email address on my personal page of the Uni. I am currently in GMT-6 timezone and the best time this week would be Wednesday at 8 am.

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

No branches or pull requests

2 participants