diff --git a/.travis.yml b/.travis.yml index aae5970b5..684a04fcf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,6 +65,8 @@ script: elseif ENV["GROUP"] == "SV" include(Pkg.dir("Turing")*"/benchmarks/install_deps.jl"); include(Pkg.dir("Turing")*"/benchmarks/sv.run.jl") + elseif ENV["GROUP"] == "NB" + include(Pkg.dir("Turing")*"/example-models/aistats2018/naive-bayes.run.jl") elseif ENV["GROUP"] == "Opt" include(Pkg.dir("Turing")*"/benchmarks/install_deps.jl"); include(Pkg.dir("Turing")*"/benchmarks/optimization.jl") diff --git a/REQUIRE b/REQUIRE index 0a804be92..fc75ba163 100644 --- a/REQUIRE +++ b/REQUIRE @@ -3,6 +3,7 @@ julia 0.6 Stan Distributions 0.11.0 ForwardDiff +ReverseDiff Mamba ProgressMeter diff --git a/benchmarks/MoC-stan.run.jl b/benchmarks/MoC-stan.run.jl index c262baf8d..0d04db3b6 100644 --- a/benchmarks/MoC-stan.run.jl +++ b/benchmarks/MoC-stan.run.jl @@ -9,7 +9,7 @@ include(Pkg.dir("Turing")*"/example-models/stan-models/MoC-stan.model.jl") stan_model_name = "Naive_Bayes" nbstan = Stanmodel(Sample(algorithm=Stan.Hmc(Stan.Static(0.05),Stan.diag_e(),0.01,0.0), save_warmup=true,adapt=Stan.Adapt(engaged=false)), - num_samples=2000, num_warmup=0, thin=1, + num_samples=5000, num_warmup=0, thin=1, name=stan_model_name, model=naivebayesstanmodel, nchains=1); rc, nb_stan_sim = stan(nbstan, nbstandata, CmdStanDir=CMDSTAN_HOME, summary=false); @@ -17,12 +17,12 @@ rc, nb_stan_sim = stan(nbstan, nbstandata, CmdStanDir=CMDSTAN_HOME, summary=fals stan_d_raw = Dict() for i = 1:4, j = 1:10 - stan_d_raw["phi[$i][$j]"] = nb_stan_sim[1001:2000, ["phi.$i.$j"], :].value[:] + stan_d_raw["phi[$i][$j]"] = nb_stan_sim[1001:end, ["phi.$i.$j"], :].value[:] end stan_d = Dict() for i = 1:4 - stan_d["phi[$i]"] = mean([[stan_d_raw["phi[$i][$k]"][j] for k = 1:10] for j = 1:1000]) + stan_d["phi[$i]"] = mean([[stan_d_raw["phi[$i][$k]"][j] for k = 1:10] for j = 1:(nbstan.num_samples-1000)]) end nb_time = get_stan_time(stan_model_name) diff --git a/benchmarks/MoC.run.jl b/benchmarks/MoC.run.jl index 6efbca05b..99e5e34d3 100644 --- a/benchmarks/MoC.run.jl +++ b/benchmarks/MoC.run.jl @@ -6,9 +6,11 @@ include(Pkg.dir("Turing")*"/benchmarks/benchmarkhelper.jl") include(Pkg.dir("Turing")*"/example-models/stan-models/MoC-stan.data.jl") include(Pkg.dir("Turing")*"/example-models/stan-models/MoC.model.jl") +setadbackend(:reverse_diff) + tbenchmark("HMC(20, 0.01, 5)", "nbmodel", "data=nbstandata[1]") -bench_res = tbenchmark("HMC(2000, 0.01, 5)", "nbmodel", "data=nbstandata[1]") +bench_res = tbenchmark("HMC(5000, 0.01, 5)", "nbmodel", "data=nbstandata[1]") # bench_res = tbenchmark("HMCDA(1000, 0.65, 0.3)", "nbmodel", "data=nbstandata[1]") # bench_res = tbenchmark("NUTS(2000, 0.65)", "nbmodel", "data=nbstandata[1]") bench_res[4].names = ["phi[1]", "phi[2]", "phi[3]", "phi[4]"] diff --git a/benchmarks/benchmarkhelper.jl b/benchmarks/benchmarkhelper.jl index 134b68feb..7da42f2f4 100644 --- a/benchmarks/benchmarkhelper.jl +++ b/benchmarks/benchmarkhelper.jl @@ -1,13 +1,14 @@ # Get running time of Stan get_stan_time(stan_model_name::String) = begin s = readlines(pwd()*"/tmp/$(stan_model_name)_samples_1.csv") - m = match(r"(?