Conversation
If transformer is not present in configuration, HGN will extract q and p from the latent encoding. The encoder and hnn must handle dimensions appropriately.
Comment on lines
+171
to
+176
| if self.transformer is not None: | ||
| latent_shape = (1, self.encoder.out_mean.out_channels, img_shape[0], | ||
| img_shape[1]) | ||
| else: # TODO: Don't hardcode shape | ||
| latent_shape = (1, int(self.encoder.out_mean.out_channels), 4, 4) | ||
| latent_representation = torch.randn(latent_shape).to(self.device).requires_grad_() |
Member
There was a problem hiding this comment.
Not sure if I understand this if else
Comment on lines
+65
to
+72
| if "transformer" in params["networks"]: | ||
| transformer = TransformerNet( | ||
| in_channels=params["networks"]["encoder"]["out_channels"], | ||
| **params["networks"]["transformer"], | ||
| dtype=dtype).to(device) | ||
| decoder_in_channels = params["networks"]["transformer"]["out_channels"] | ||
| else: | ||
| transformer = None |
Member
There was a problem hiding this comment.
Isn't that what def instantiate_transformer is doing?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request makes HGN work without the transformer. If
transformeris not present undernetworksin the configuration, HGN will not use it. The latent encoding will be split intoqandpand used. Therefore, the encoder and hamiltonian networks should handle dimensions appropriately.I updated the
train_config_no_transformer.yamlby making the latent encoding of 32 channels instead of 48, so that q and p are of 16 channels each.