-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:yebai/Turing.jl
- Loading branch information
Showing
19 changed files
with
158 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,18 @@ | ||
using Distributions | ||
using Turing | ||
using Stan | ||
include(Pkg.dir("Turing")*"/benchmarks/benchmarkhelper.jl") | ||
|
||
# NOTE: put Stan models before Turing ones if you want to compare them in print_log | ||
CONFIG = Dict( | ||
"model-list" => [ | ||
"gdemo-geweke", | ||
#"normal-loc", | ||
"normal-mixture", | ||
"gdemo", | ||
"gauss", | ||
"bernoulli", | ||
#"negative-binomial", | ||
"school8", | ||
"binormal", | ||
"kid" | ||
], | ||
|
||
"test-level" => 2 # 1 = model lang, 2 = whole interface | ||
) | ||
|
||
if CONFIG["test-level"] == 1 | ||
|
||
println("Turing compiler test started.") | ||
|
||
for model in CONFIG["model-list"] | ||
println("Tesing `$model` ... ") | ||
include("$(model).run.jl") | ||
println("✓") | ||
end | ||
|
||
println("Turing compiler test passed.") | ||
|
||
elseif CONFIG["test-level"] == 2 | ||
|
||
println("Turing benchmarking started.") | ||
|
||
for model in CONFIG["model-list"] | ||
println("Benchmarking `$model` ... ") | ||
job = `julia -e " cd(\"$(pwd())\");include(dirname(\"$(@__FILE__)\")*\"/benchmarkhelper.jl\"); | ||
CMDSTAN_HOME = \"$CMDSTAN_HOME\"; | ||
using Turing, Distributions, Stan; | ||
include(dirname(\"$(@__FILE__)\")*\"/$(model).run.jl\") "` | ||
println(job); run(job) | ||
println("`$model` ✓") | ||
end | ||
|
||
println("Turing benchmarking completed.") | ||
|
||
end | ||
model_list = ["gdemo-geweke", | ||
#"normal-loc", | ||
"normal-mixture", | ||
"gdemo", | ||
"gauss", | ||
"bernoulli", | ||
#"negative-binomial", | ||
"school8", | ||
"binormal", | ||
"kid"] | ||
|
||
benchmakr_turing(model_list) |
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Turing | ||
using Distributions | ||
using Base.Test | ||
|
||
@model test_ex_rt() = begin | ||
x ~ Normal(10, 1) | ||
y ~ Normal(x / 2, 1) | ||
z = y + 1 | ||
x = x - 1 | ||
x, y, z | ||
end | ||
|
||
mf = test_ex_rt() | ||
|
||
for alg = [HMC(2000, 0.2, 3), PG(20, 2000), SMC(10000), IS(10000), Gibbs(2000, PG(20, 1, :x), HMC(1, 0.2, 3, :y))] | ||
println("[explicit_ret.jl] testing $alg") | ||
chn = sample(mf, alg) | ||
@test_approx_eq_eps mean(chn[:x]) 9.0 0.2 | ||
@test_approx_eq_eps mean(chn[:y]) 5.0 0.2 | ||
@test_approx_eq_eps mean(chn[:z]) 6.0 0.2 | ||
end |
Oops, something went wrong.