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
using InteractiveUtils | |
versioninfo() | |
using DrWatson | |
@quickactivate | |
using Comonicon, Test, BenchmarkTools, ExprOptimization | |
using ExprOptimization.ProbabilisticExprRules: RuleNode, mindepth_map, ProbabilisticGrammar | |
using GeneralizedGenerated: mk_function |
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
struct TakeUntil{I} | |
cond::Function | |
xs::I | |
end | |
""" | |
takeuntil(cond, xs) | |
An iterator that yields values from the iterator `xs` as long as the | |
predicate `cond` is true. Unlike `takewhile`, it also take the last | |
value for which the predicate `cond` is false. |
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
using Random: AbstractRNG, GLOBAL_RNG | |
using AdvancedHMC: PhasePoint, phasepoint | |
function AdvancedHMC.refresh( | |
rng::Union{AbstractRNG, AbstractVector{<:AbstractRNG}}, | |
z::PhasePoint{T}, | |
h::Hamiltonian | |
) where {T<:CuArray} | |
r = CuArray{Float32, 2}(undef, size(h.metric)...) | |
CUDA.CURAND.randn!(r) |
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
# Modifed from https://github.com/cambridge-mlg/Covid19/blob/master/src/utils.jl#L79 | |
function generated_quantities(m::Turing.Model, c::MCMCChains.Chains) | |
# If `c` is multiple chains, we convert them into a single chain | |
chain = length(chains(c)) == 1 ? c : MCMCChains.pool_chain(c) | |
vi = Turing.DynamicPPL.VarInfo(m) | |
return map(1:length(chain)) do i | |
Turing.DynamicPPL._setval!(vi, chain[i]) | |
m(vi) | |
end | |
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
using LibGit2 | |
LibGit2.set_ssl_cert_locations("/etc/ssl/certs/ca-certificates.crt") |