QUVA-Lab / e2cnn

E(2)-Equivariant CNNs Library for Pytorch

Home Page:https://quva-lab.github.io/e2cnn/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Result of equivariance test changes after training model

kbbernander opened this issue · comments

Hi, thanks again for a very nice package and your support of it.

When I am running my own architecture, there seems to be some kind of problem with its equivariance properties after training.

I am using my own dataset contaning biomedical images, and the classifier needs to classify cancer being present or not. So therefore there are two classes. When I run the test function on an image on the test set, I get these results:

#############################################################################

angle | 0 1 2 3 4 5 6 7 8 9
0 : [-0.0123 -0.2154]
90 : [-0.0118 -0.2155]
180 : [-0.0126 -0.2156]
270 : [-0.012 -0.2157]
#############################################################################

So the network has a high degree of equivariance.

Then I train my model, run the same test function again and I get these results:

#############################################################################
angle | 0 1 2 3 4 5 6 7 8 9
0 : [-1.6111 1.8046]
90 : [-1.0136 1.043 ]
180 : [-1.3092 1.5487]
270 : [-1.5571 1.8682]
#############################################################################

Meaning very different outputs even though I use the C4 group. Any insight into what could be happening to 'break' the equivariance properties of the network?

Hi @Tarnekar

this is indeed strange. If the network does not contain any operations which break equivariance, C4 equivariance should be guaranteed.

A potential cause is pooling (e.g. max pooling or strided convolution).
If you apply 2x2 max pooling over a 11x11 image, a 90 degrees rotation will change the windows where the 2x2 kernel is placed.
Similarly, when using a stride 2 convolution with a 3x3 filter over a 10x10 image with zero padding, a rotation by 90 degrees will change the points where the filter is sampled.
In both cases, 90 degrees rotations produce different outputs.
Is this the case for you?
If so, in the first case, make sure your features and images have even sizes, while in the second you should use grids with odd sides.

Best,
Gabriele

Thanks for the answer and sorry for the late reply. I am in the process of redesigning the architecture with your pointers in mind.

Best
tarnekar

The issue is solved now, I have the expected equivariance! Again, thanks a lot for the help!

Hi @Tarnekar

Good to read this!

I'm happy my comment was helpful!