New unifying structure for coupling architectures#139
Draft
New unifying structure for coupling architectures#139
Conversation
fdraxler
commented
Nov 11, 2022
|
|
||
| class Positive(Parameter): | ||
| def constrain(self, unconstrained: torch.Tensor) -> torch.Tensor: | ||
| return torch.exp(unconstrained) |
Collaborator
Author
There was a problem hiding this comment.
I think we should have something like SoftPositive that saturates at a certain value.
|
|
||
| class Increasing(Parameter): | ||
| def constrain(self, unconstrained: torch.Tensor) -> torch.Tensor: | ||
| return unconstrained[:, 0] + torch.cumsum(torch.exp(unconstrained[:, 1:]), dim=1) |
|
|
||
| def parameterize(**parameters): | ||
| def wrap(cls): | ||
| def construct(*args, split=EvenSplit(), subnet_constructor, **kwargs): |
Collaborator
Author
There was a problem hiding this comment.
@wraps(cls) for future docstring
| self.split = split | ||
| self.transform = transform | ||
| # TODO: 2 subnets? or just singular coupling? | ||
| self.subnet = subnet |
Collaborator
Author
There was a problem hiding this comment.
I am in favor of just one, but maybe we should check the most recent literature.
|
|
||
| def get_parameters(self, condition: torch.Tensor) -> Dict[str, torch.Tensor]: | ||
| parameters = self.subnet(condition) | ||
| parameters = torch.split(parameters, self.parameter_counts, dim=1) |
Collaborator
Author
There was a problem hiding this comment.
How should we handle shapes? Always split at first non-batch dimension? Could also be a parameter to the Coupling.
|
|
||
|
|
||
|
|
||
| class Coupling(Transform): |
Collaborator
Author
There was a problem hiding this comment.
We should think about the final API we want have. What goes here?
inn = SequenceINN()
inn.append(...)
playground.py
Outdated
| def forward(self, x: torch.Tensor) -> torch.Tensor: | ||
| x1, x2 = self.split.forward(x) | ||
| parameters = self.get_parameters(x2) | ||
| z1 = self.transform.forward(x1, **parameters) |
| parameters = self.get_parameters(x2) | ||
| z1 = self.transform.forward(x1, **parameters) | ||
| parameters = self.get_parameters(z1) | ||
| z2 = self.transform.forward(x2, **parameters) |
Collaborator
Author
There was a problem hiding this comment.
Make consistent with one/double coupling choice above.
|
Is there someone working on this repository? He looks very stopped |
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.
No description provided.