-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unifying trajectories #214
Closed
Closed
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
31c6517
add regression test against master
xukai92 097dc3f
rename EndPointTS to MetropolisTS
xukai92 27668bd
rename GeneralisedNoUTurn to NoUTurn
xukai92 72309f8
update static trajectories
xukai92 52827b9
update dynamic trajectories
xukai92 8878944
Support a richer interface for NUTS
xukai92 04f621e
Apply suggestions from code review
xukai92 9425d27
add missing imports
xukai92 c827dca
fix Hong's typo
xukai92 28887ca
fix geweke
xukai92 d17d79d
name back no-U-turns
xukai92 89f9b43
remove unnecessary interface for test
xukai92 cf0e5fc
AbstractKernel -> AbstractKernel
xukai92 ddc56f2
FixedLength -> FixedIntegrationTime
xukai92 90b06cb
Update src/trajectory.jl
xukai92 086590d
make internal naming more descriptive
xukai92 7c5d344
remove old comments
xukai92 cbd1234
Revert "remove old comments"
xukai92 237138f
rename TS to trajectory_sampler_type
xukai92 200b52f
improve internal namings
xukai92 242dc4e
push test toml
xukai92 c59a739
lower bound 1.3 on Travis
xukai92 e39aa93
Improve badge
xukai92 68d1452
Update src/trajectory.jl
xukai92 0e9200f
Update src/trajectory.jl
xukai92 bde50d8
resolve conflicts
xukai92 3c06f2d
Apply suggestions from code review
xukai92 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.vscode | ||
.history | ||
.DS_Store | ||
Manifest.toml | ||
test/Project.toml |
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 |
---|---|---|
|
@@ -12,8 +12,7 @@ os: | |
- osx | ||
|
||
julia: | ||
- 1.0 | ||
- 1 | ||
- 1.3 | ||
- nightly | ||
|
||
matrix: | ||
|
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 | ||||
---|---|---|---|---|---|---|
|
@@ -7,22 +7,30 @@ using LinearAlgebra: Symmetric, UpperTriangular, mul!, ldiv!, dot, I, diag, chol | |||||
using StatsFuns: logaddexp, logsumexp | ||||||
using Random: GLOBAL_RNG, AbstractRNG | ||||||
using ProgressMeter: ProgressMeter | ||||||
using Parameters: @unpack, reconstruct | ||||||
using Parameters: @with_kw, @unpack, reconstruct | ||||||
using ArgCheck: @argcheck | ||||||
|
||||||
using DocStringExtensions: TYPEDEF, TYPEDFIELDS | ||||||
using DocStringExtensions: SIGNATURES, TYPEDEF, TYPEDFIELDS | ||||||
|
||||||
import StatsBase: sample | ||||||
import Parameters: reconstruct | ||||||
|
||||||
include("utilities.jl") | ||||||
|
||||||
# Notations | ||||||
# ℓπ: log density of the target distribution | ||||||
# θ: position variables / model parameters | ||||||
# ∂ℓπ∂θ: gradient of the log density of the target distribution w.r.t θ | ||||||
# r: momentum variables | ||||||
# z: phase point / a pair of θ and r | ||||||
# θ₀: initial position | ||||||
# r₀: initial momentum | ||||||
# z₀: initial phase point | ||||||
# ℓπ: log density of the target distribution | ||||||
# ∇ℓπ: gradient of the log density of the target distribution w.r.t θ | ||||||
# κ: kernel | ||||||
# τ: trajectory | ||||||
# ϵ: leap-frog integration step size | ||||||
# L: leap-frog integration step number | ||||||
# λ: leap-frog integration time | ||||||
|
||||||
include("metric.jl") | ||||||
export UnitEuclideanMetric, DiagEuclideanMetric, DenseEuclideanMetric | ||||||
|
@@ -35,12 +43,39 @@ export Leapfrog, JitteredLeapfrog, TemperedLeapfrog | |||||
|
||||||
include("trajectory.jl") | ||||||
@deprecate find_good_eps find_good_stepsize | ||||||
export EndPointTS, SliceTS, MultinomialTS, | ||||||
StaticTrajectory, HMCDA, NUTS, | ||||||
ClassicNoUTurn, GeneralisedNoUTurn, | ||||||
StrictGeneralisedNoUTurn, | ||||||
export Trajectory, HMCKernel, | ||||||
FixedNSteps, FixedIntegrationTime, | ||||||
ClassicNoUTurn, GeneralisedNoUTurn, NoUTurn, StrictGeneralisedNoUTurn, StrictNoUTurn, | ||||||
MetropolisTS, SliceTS, MultinomialTS, | ||||||
find_good_stepsize | ||||||
|
||||||
# Deprecations for trajectory.jl | ||||||
|
||||||
abstract type AbstractTrajectory end | ||||||
|
||||||
struct HMC{TS} end | ||||||
HMC{TS}(int::AbstractIntegrator, L) where {TS} = HMCKernel(Trajectory(int, FixedNSteps(L)), TS) | ||||||
HMC(int::AbstractIntegrator, L) = HMC{MetropolisTS}(int, L) | ||||||
HMC(ϵ::AbstractScalarOrVec{<:Real}, L) = HMC{MetropolisTS}(Leapfrog(ϵ), L) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
struct StaticTrajectory{TS} end | ||||||
@deprecate StaticTrajectory{TS}(args...) where {TS} HMC{TS}(args...) | ||||||
@deprecate StaticTrajectory(args...) HMC(args...) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar here, consider calling |
||||||
|
||||||
struct HMCDA{TS} end | ||||||
HMCDA{TS}(int::AbstractIntegrator, λ) where {TS} = HMCKernel(Trajectory(int, FixedIntegrationTime(λ)), TS) | ||||||
HMCDA(int::AbstractIntegrator, λ) = HMCDA{MetropolisTS}(int, λ) | ||||||
HMCDA(ϵ::AbstractScalarOrVec{<:Real}, λ) = HMCDA{MetropolisTS}(Leapfrog(ϵ), λ) | ||||||
|
||||||
struct NUTS{TS, TC} end | ||||||
NUTS{TS, TC}(int::AbstractIntegrator, args...; kwargs...) where {TS, TC} = | ||||||
HMCKernel(Trajectory(int, TC(args...; kwargs...)), TS) | ||||||
NUTS(int::AbstractIntegrator, args...; kwargs...) = | ||||||
NUTS{MultinomialTS, GeneralisedNoUTurn}(int, args...; kwargs...) | ||||||
NUTS(ϵ::AbstractScalarOrVec{<:Real}) = NUTS{MultinomialTS, GeneralisedNoUTurn}(Leapfrog(ϵ)) | ||||||
|
||||||
export AbstractTrajectory, HMC, StaticTrajectory, HMCDA, NUTS | ||||||
xukai92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
include("adaptation/Adaptation.jl") | ||||||
using .Adaptation | ||||||
import .Adaptation: StepSizeAdaptor, MassMatrixAdaptor, StanHMCAdaptor, NesterovDualAveraging | ||||||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe consider the following for clarity and performance?