survae_flows
survae_flows copied to clipboard
question about SimpleAbsSurjection function
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 ?
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.
Thank you for your clarification!