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

question about SimpleAbsSurjection function #17

Open
Fangwq opened this issue Jun 18, 2021 · 2 comments
Open

question about SimpleAbsSurjection function #17

Fangwq opened this issue Jun 18, 2021 · 2 comments

Comments

@Fangwq
Copy link

Fangwq commented Jun 18, 2021

I read the code recently and feel confused about the class SimpleAbsSurjection. The part of code is following:

    def forward(self, x):
        z = x.abs()         
        ldj = - x.new_ones(x.shape[0]) * math.log(2) * x.shape[1:].numel()
        return z, ldj

why should we multiply this term x.shape[1:].numel()? where does it come from? Any clues does I miss ?

@didriknielsen
Copy link
Owner

Hi, thanks for your question!

This is the number of dimensions in your data. By default, this layer applies the abs transformation to every element in the data, hence you need to scale by log(2) once per element.

@Fangwq
Copy link
Author

Fangwq commented Jun 19, 2021

Thank you for your clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants