deepsphere / deepsphere-cosmo-tf2

A spherical convolutional neural network for cosmology (TFv2).
https://arxiv.org/abs/1810.12186
MIT License
19 stars 6 forks source link

Regarding the Autoencoder model #12

Open Wasim04 opened 8 months ago

Wasim04 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 7 months ago

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 86d5e6de197e17353daed612a8e08477d49cba9a). 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 commented 7 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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.