Skip to content

Commit

Permalink
Perfect coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gdalle committed Jun 10, 2024
1 parent 1054068 commit a517845
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ The following estimators are implemented:

- [REINFORCE](https://jmlr.org/papers/volume21/19-346/19-346.pdf#section.20)
- [Reparametrization](https://jmlr.org/papers/volume21/19-346/19-346.pdf#section.56)

> Warning: this package is experimental, use at your own risk and expect frequent breaking releases.
10 changes: 10 additions & 0 deletions test/expectation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ using Zygote
exp_with_kwargs(x; correct=false) = correct ? exp(x) : sin(x)
vec_exp_with_kwargs(x; correct=false) = exp_with_kwargs.(x; correct)

normal_logdensity_grad(x, θ...) = gradient((_θ...) -> logpdf(Normal(_θ...), x), θ...)

μ, σ = 0.5, 1.0
true_mean(μ, σ) = mean(LogNormal(μ, σ))
true_std(μ, σ) = std(LogNormal(μ, σ))
Expand All @@ -26,6 +28,14 @@ true_std(μ, σ) = std(LogNormal(μ, σ))
nb_samples=10^4,
threaded=threaded,
),
Reinforce(
exp_with_kwargs,
Normal,
normal_logdensity_grad;
rng=StableRNG(63),
nb_samples=10^4,
threaded=threaded,
),
Reparametrization(
exp_with_kwargs,
Normal;
Expand Down

0 comments on commit a517845

Please sign in to comment.