API reference
Public
DifferentiableExpectations.DifferentiableExpectations
— ModuleDifferentiableExpectations
A Julia package for differentiating through expectations with Monte-Carlo estimates.
Exports
DifferentiableExpectations.DifferentiableExpectation
— TypeDifferentiableExpectation{threaded}
Abstract supertype for differentiable parametric expectations F : θ -> 𝔼[f(X)]
where X ∼ p(θ)
, whose value and derivative are approximated with Monte-Carlo averages.
Type parameters
threaded::Bool
: specifies whether the sampling should be performed in parallel (with OhMyThreads.jl)
Required fields
f
: the function applied inside the expectationdist_constructor
: the constructor of the probability distribution, such that callingD(θ...)
generates an object corresponding top(θ)
rng
: the random number generatornb_samples
: the number of Monte-Carlo samples
DifferentiableExpectations.DifferentiableExpectation
— Method(F::DifferentiableExpectation)(θ...; kwargs...)
Return a Monte-Carlo average (1/s) ∑f(xᵢ)
where the xᵢ ∼ p(θ)
are iid samples.
DifferentiableExpectations.FixedAtomsProbabilityDistribution
— TypeFixedAtomsProbabilityDistribution
A probability distribution with finite support and fixed atoms.
Whenever its expectation is differentiated, only the weights are considered active, whereas the atoms are considered constant.
Fields
atoms::Vector
weights::Vector
DifferentiableExpectations.REINFORCE
— TypeREINFORCE{threaded} <: DifferentiableExpectation{threaded}
Differentiable parametric expectation F : θ -> 𝔼[f(X)]
where X ∼ p(θ)
using the REINFORCE (or score function) gradient estimator:
∂F(θ) = 𝔼[f(X) ∇₁logp(θ, x)ᵀ]
Constructor
REINFORCE(
+API reference · DifferentiableExpectations.jl API reference
Public
DifferentiableExpectations.DifferentiableExpectations
— ModuleDifferentiableExpectations
A Julia package for differentiating through expectations with Monte-Carlo estimates.
Exports
sourceDifferentiableExpectations.DifferentiableExpectation
— TypeDifferentiableExpectation{threaded}
Abstract supertype for differentiable parametric expectations F : θ -> 𝔼[f(X)]
where X ∼ p(θ)
, whose value and derivative are approximated with Monte-Carlo averages.
Type parameters
threaded::Bool
: specifies whether the sampling should be performed in parallel (with OhMyThreads.jl)
Required fields
f
: the function applied inside the expectationdist_constructor
: the constructor of the probability distribution, such that calling D(θ...)
generates an object corresponding to p(θ)
rng
: the random number generatornb_samples
: the number of Monte-Carlo samples
sourceDifferentiableExpectations.DifferentiableExpectation
— Method(F::DifferentiableExpectation)(θ...; kwargs...)
Return a Monte-Carlo average (1/s) ∑f(xᵢ)
where the xᵢ ∼ p(θ)
are iid samples.
sourceDifferentiableExpectations.FixedAtomsProbabilityDistribution
— TypeFixedAtomsProbabilityDistribution
A probability distribution with finite support and fixed atoms.
Whenever its expectation is differentiated, only the weights are considered active, whereas the atoms are considered constant.
Fields
atoms::Vector
weights::Vector{W} where W<:Real
sourceDifferentiableExpectations.REINFORCE
— TypeREINFORCE{threaded} <: DifferentiableExpectation{threaded}
Differentiable parametric expectation F : θ -> 𝔼[f(X)]
where X ∼ p(θ)
using the REINFORCE (or score function) gradient estimator:
∂F(θ) = 𝔼[f(X) ∇₁logp(θ, x)ᵀ]
Constructor
REINFORCE(
f,
dist_constructor,
dist_gradlogpdf=nothing;
rng=Random.default_rng(),
nb_samples=1,
threaded=false
-)
Fields
f::Any
dist_constructor::Any
dist_logdensity_grad::Any
rng::Random.AbstractRNG
nb_samples::Int64
See also
sourcePrivate
DifferentiableExpectations.presamples
— Methodpresamples(F::DifferentiableExpectation, θ...)
Return a vector [x₁, ..., xₛ]
or matrix [x₁ ... xₛ]
where the xᵢ ∼ p(θ)
are iid samples.
sourceDifferentiableExpectations.samples
— Methodsamples(F::DifferentiableExpectation, θ...; kwargs...)
Return a vector [f(x₁), ..., f(xₛ)]
where the xᵢ ∼ p(θ)
are iid samples.
sourceSettings
This document was generated with Documenter.jl version 1.4.1 on Monday 10 June 2024. Using Julia version 1.10.4.
+)
Fields
f::Any
dist_constructor::Any
dist_logdensity_grad::Any
rng::Random.AbstractRNG
nb_samples::Int64
See also
Private
DifferentiableExpectations.presamples
— Methodpresamples(F::DifferentiableExpectation, θ...)
Return a vector [x₁, ..., xₛ]
or matrix [x₁ ... xₛ]
where the xᵢ ∼ p(θ)
are iid samples.
DifferentiableExpectations.samples
— Methodsamples(F::DifferentiableExpectation, θ...; kwargs...)
Return a vector [f(x₁), ..., f(xₛ)]
where the xᵢ ∼ p(θ)
are iid samples.