TuringLang / Bijectors.jl

Implementation of normalising flows and constrained random variable transformations
https://turinglang.org/Bijectors.jl/
MIT License
200 stars 33 forks source link

Matrix Variate Bijectors - Lower/Uppertriangular transforms #215

Open paschermayr opened 2 years ago

paschermayr commented 2 years ago

Dear all,

I wanted to ask why a PDBijector transforms the input to a lowertriangular matrix while a CorrBijector transforms the input into a uppertriangular matrix. It seems like most AD libraries evaluate gradients based on a upper triangular matrix, hence I have troubles with the PDBijector:

using Bijectors
mat = [1. .3 ; .3 1.]
bij_1 = Bijectors.PDBijector()
bij_2 = Bijectors.CorrBijector()

mat_1_transformed = bij_1(mat)
#=
2×2 Matrix{Float64}:
 0.0   0.0
 0.3  -0.0471553
=#
mat_2_transformed = bij_2(mat)
#=
2×2 Matrix{Float64}:
 0.0  0.30952
 0.0  0.0
=#

Is there any chance that PDBijector might return a uppertriangular matrix too?

Best regards, Patrick