pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.33k stars 3.66k forks source link

Visualize filters learned by GMMConv #1703

Closed adhikarirsr closed 2 years ago

adhikarirsr commented 4 years ago

How to visualize filters learned by GMMConv?

I have GMMConv layers: self.conv1 = GMMConv(1, 16,dim=2, kernel_size=5,separate_gaussians=True) self.conv2 = GMMConv(16, 1,dim=2, kernel_size=5,separate_gaussians=True)

Some questions:

  1. Here, conv1 has 16 5X5 filters, right?
  2. These filters should look like CNN filters if I am using a grid graph, right?
  3. If I set separate_gaussians=False, does GMMConv act like isotropic GNNs?
rusty1s commented 4 years ago

Hi and thanks for your interest! The GMMConv is a bit different from classical CNNs since it will learn kernel_size Gaussians which define the kernel points (in fact, it's similar to attention based on edge features).

Those are accessible via self.mu and self.sigma`, and you can plot them similar to Figure 1 in the MoNet paper.

Therefore:

  1. It will have 16 * 5 filters.
  2. Not exactly, since kernel points are modelled as Gaussians and are trainable.
  3. In case separate_gaussians=False, the Gaussians are shared across the features, so it will only learn 5 filters (which corresponds to the original MoNet formulation).