Skip to content

Conversation

VolodyaCO
Copy link
Collaborator

The encoder might not encode a datapoint x to a 1D spin string. In the case of autoencoders where vector quantisation layers are added, encoders might encode a datapoint x to a HxWxC array. In such a case, the default latent to discrete transformation would be wrong, as it expected only a single feature dimension, whereas in this case there are three such feature dimensions.

This PR fixes that by automatically finding the number of feature dimensions in the encoded data representation, and performs the gumbel softmax transformation accordingly, keeping the same number of feature dimensions.

@VolodyaCO VolodyaCO self-assigned this Sep 2, 2025
@VolodyaCO VolodyaCO added the enhancement New feature or request label Sep 2, 2025
Copy link
Contributor

@thisac thisac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @VolodyaCO. Don't forget to add a an entry to the release-log.

@VolodyaCO
Copy link
Collaborator Author

@thisac I don't understand very well the reno process for release notes. Is every PR intended to create a new release?

@VolodyaCO
Copy link
Collaborator Author

@thisac nvm, I just read "All of the list items in this section are combined when the release notes are rendered"

@VolodyaCO VolodyaCO force-pushed the feature/flexible-features-in-latent-to-discrete branch 2 times, most recently from 7dd9d16 to 4119f2d Compare September 7, 2025 18:47
@VolodyaCO VolodyaCO force-pushed the feature/flexible-features-in-latent-to-discrete branch from 4119f2d to a3ec9ec Compare September 19, 2025 15:37
Copy link
Collaborator

@anahitamansouri anahitamansouri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much Vlad for the nice PR. I've added a few minor comments.

if __name__ == "__main__":
unittest.main()
unittest.main()
unittest.main()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this redundant? If so, please remove it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, it is! thanks for noticing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it!


def forward(self, x: torch.Tensor) -> torch.Tensor:
return x * 20 - 10
# x is of shape (batch_size, replica_size, l1, l2, ...)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's replica_size here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gumbel softmax sampling is non-deterministic (depends on the random seed). The DVAE can be told how many times to sample from the logits. This number of times is the replica size. This is documented in the forward method of the DVAE, but it's called n_samples instead of replica_size. I will change this accordingly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this to n_samples.

@VolodyaCO VolodyaCO force-pushed the feature/flexible-features-in-latent-to-discrete branch from 5225ee0 to 673a581 Compare September 22, 2025 19:42
fix number of feature dimensions

[docs] consistent notation

release

ignore files in aim

testing different number of latent dimensions

extend tests to more feature dimensions

Update tests/test_dvae_winci2020.py

Co-authored-by: Anahita Mansouri Bigvand <[email protected]>

Update tests/test_dvae_winci2020.py

Co-authored-by: Anahita Mansouri Bigvand <[email protected]>

Update tests/test_dvae_winci2020.py

Co-authored-by: Anahita Mansouri Bigvand <[email protected]>
@VolodyaCO VolodyaCO force-pushed the feature/flexible-features-in-latent-to-discrete branch from 673a581 to 3b81ea8 Compare September 22, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants