survae_flows icon indicating copy to clipboard operation
survae_flows copied to clipboard

question about SimpleAbsSurjection function

Open Fangwq opened this issue 3 years ago • 2 comments

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 ?

Fangwq avatar Jun 18 '21 15:06 Fangwq

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.

didriknielsen avatar Jun 18 '21 15:06 didriknielsen

Thank you for your clarification!

Fangwq avatar Jun 19 '21 06:06 Fangwq