-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update DistributionsAD support (#89)
* update DistribtuionsAD and Zygote * bump Zygote and DAD comapt versions * minor fix
- Loading branch information
1 parent
86c6a67
commit e4065e9
Showing
5 changed files
with
58 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
struct PDBijector <: Bijector{2} end | ||
|
||
function replace_diag(X, y) | ||
f(i, j) = ifelse(i == j, y[i], X[i, j]) | ||
return f.(1:size(X, 1), (1:size(X, 2))') | ||
function replace_diag(f, X) | ||
g(i, j) = ifelse(i == j, f(X[i, i]), X[i, j]) | ||
return g.(1:size(X, 1), (1:size(X, 2))') | ||
end | ||
function (b::PDBijector)(X::AbstractMatrix{<:Real}) | ||
Y = cholesky(X).L | ||
return replace_diag(Y, log.(diag(Y))) | ||
return replace_diag(log, Y) | ||
end | ||
function (ib::Inverse{<:PDBijector})(Y::AbstractMatrix{<:Real}) | ||
X = replace_diag(Y, exp.(diag(Y))) | ||
X = replace_diag(exp, Y) | ||
return LowerTriangular(X) * LowerTriangular(X)' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters