Skip to content

Serious bug: .view used instead of .t() in _estimate_latent_entropies causes wrong MIG results #78

@carl-allen

Description

@carl-allen

There is a serious bug in the implementation of _estimate_latent_entropies in evaluate.py that can cause incorrect Mutual Information Gap (MIG) scores.

The code currently uses the following line to reshape after sampling latent codes:

samples_zCx = samples_zCx.index_select(0, samples_x).view(latent_dim, n_samples)

This is not a transpose, but a reshape, and will reorder memory rather than transpose the axes. This yields incorrect results unless the tensor is laid out in memory exactly as expected, which is rare and not robust.

Correct code:

samples_zCx = samples_zCx.index_select(0, samples_x).t()

This bug can cause all downstream mutual information and MIG metric calculations to be silently wrong.

Recommendation: Replace .view(latent_dim, n_samples) with .t() and review all other uses of .view that are intended to transpose axes. Consider adding a test to catch such errors.

Thanks for your attention!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions