anvoynov / GANLatentDiscovery

The authors official implementation of Unsupervised Discovery of Interpretable Directions in the GAN Latent Space
416 stars 52 forks source link

Can the number of directions be larger than the dimesnionality of the latent space? #18

Closed chi0tzp closed 3 years ago

chi0tzp commented 3 years ago

For target_indices you sample batch_size integers from [0, ..., directions_count-1] and then you create z_shift as a batch_size x latent_dim matrix, where for each row, at the column defined by target_indices vector, you assign a (random) shift magnitude value.

However, if directions_count > latent_dim, then this would fail, since you would try to assign a shift magnitude to a non-existent column of z_shift (it has only latent_dim columns). This effectively means that (at least with this version of the code), you cannot discover more directions than the dimensionality of the latent space (you can discover at most as many directions as the dimensionality of the latent space). This might be reasonable in practice, but in the paper it is stated that "The method from (Ramesh et al., 2018) is also limited with the maximal number of discovered directions equal to the latent space dimensionality, while our approach can be applied for a higher number of directions.".

Am I missing something here? Thanks for your time.

anvoynov commented 3 years ago

The latent_dim in the make_shifts call is equal deformator.input_dim https://github.com/anvoynov/GANLatentDiscovery/blob/master/trainer.py#L195 so that latent_dim == directions_count in this method, thus it should works fine. Surprisingly, I just caught another bug related to the shift predictor dimension that could potentially strike once the directions_count is greater than the generator's latent dimension (fixed here: https://github.com/anvoynov/GANLatentDiscovery/blob/master/run_train.py#L74). The claim in the paper remains true as the approach does not rely on the latent dimensionality.