mfinzi / equivariant-MLP

A library for programmatically generating equivariant layers through constraint solving
MIT License
251 stars 21 forks source link

question about figure 2 in the paper #22

Closed Fangwq closed 10 months ago

Fangwq commented 10 months ago

Hi, I try to draw figure 2 in the paper( for example, Convolutions in section 4.3). My code is written in Mathematica:

C = {{0, 0, 0, 1}, {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}}              # rho(h), permuation matrix 
{u, sigma, q} = SingularValueDecomposition[(C - IdentityMatrix[4])]       #  SVD(rho(h) - I)
MatrixPlot[q]

The result is very different from your paper. Any mistakes I make here? Thank you very much!

mfinzi commented 10 months ago

Hi @Fangwq , I think there may be a couple issues with the code you present. The representation of the matrix mapping from $\rho(h) \rightarrow \rho(h)$ should be image

The plots in figure 2 and figure 3 are formed by taking the nullspace (rather than SVD), and then assigning colors to a basis for this nullspace, which when reshaped form an image.

I think instead the code should look something like

P = {{0, 0, 0, 1}, {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}};
M = KroneckerProduct[P, P] - IdentityMatrix[Length[tensorProduct]];
nullSpace = NullSpace[M];
rank = Length[nullSpace];
leftMultiplied = Range[1, rank] . nullSpace; # (I don't remember the syntax for the multiplication)
reshapedMatrix = ArrayReshape[leftMultiplied, {4, 4}];
MatrixPlot[reshapedMatrix]

Let me know if this answers your question

Fangwq commented 10 months ago

The answer matches perfectly. Thank you for your clarification!