Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing AffineAdapterSigmoid for 2 dimensional inputs #64

Closed
silvandeleemput opened this issue Aug 3, 2021 · 0 comments · Fixed by #67
Closed

Fixing AffineAdapterSigmoid for 2 dimensional inputs #64

silvandeleemput opened this issue Aug 3, 2021 · 0 comments · Fixed by #67
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@silvandeleemput
Copy link
Owner

Thank you for your reply, I modified it according to your description, but it brought another error.
image
image

If I use AffineAdapterNaive instead of AffineAdapterSigmoid, it works.

Btw, if you still want to use the AffineAdapterSigmoid with the AffineCoupling, you can use the following modified AffineAdapterSigmoid implemention, which should fix your error:

class AffineAdapterSigmoidModified(torch.nn.Module):
    """ Sigmoid based affine adapter, modified to work for 2 dimensional outputs

        Partitions the output h of f(x) = h into s and t by extracting every odd and even channel
        Outputs sigmoid(s), t
    """
    def __init__(self, module):
        super(AffineAdapterSigmoidModified, self).__init__()
        self.f = module

    def forward(self, x):
        h = self.f(x)
        assert h.shape[1] % 2 == 0  # nosec
        scale = torch.sigmoid(h[:, 1::2] + 2.0)
        shift = h[:, 0::2]
        return scale, shift

Originally posted by @silvandeleemput in #63 (comment)

@silvandeleemput silvandeleemput self-assigned this Aug 3, 2021
@silvandeleemput silvandeleemput added bug Something isn't working enhancement New feature or request labels Aug 3, 2021
This was referenced Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant