GAN C2W3 StyleGan2 components (opt) possible error

Hi,
I have been trying to run the optional notebook, and the vectorized implementation of the forward() method of the ModulatedConv2d class.

When running the first test, everything is fine, but the final test throws an error because of a size mismatch. Apparently, for the unrolling trick to work, the dimensions of the .view call have to match the shape of w_prime_prime
( w_prime_prime.view(batchsize * out_channels, in_channels, *w_prime_prime.shape[3:]) )

When I change this line:

out_channels = w_prime_prime.shape[2]

to

out_channels = w_prime_prime.shape[1]

It works, as the product of the dimensions match. Is this a correct solution or just coincidentally working for this example?

Hi MPS!

Welcome to the community :wave:.

I’m quite confused with your issue because every cell runs for me without any errors. Fundamentally, you don’t have to modify anything in this optional notebook, you can just go through it, observe the results and learn some interesting concepts.
Why are you trying to change the code and what do you mean by first test and second test? There are no test cells here.

Hi,

you are right, if you run the cells wihtout changing anything, then everything runs without error.
But then the vectorized forward() mehod of the ModulatedConv2d class is not used.

The error only appears when you rename the forward method to forward_classic and the vectorized implementation below to forward, and then it is actually used, and the error appears.

With test cell I meant the last cell, with “def path_length_regulization_loss …” in it. I called it a test cell since it actually calls the code and not just defines it :blush: