bayesiancnn-data-parsing/energy_measure_sum_df.jl

400 lines
16 KiB
Julia

include("aux_func.jl")
using LinearAlgebra
using Statistics
using DataFrames
using Latexify
#=
Obtain energy data
=#
#mni_folder_1 = "ini_exp_data/"
mni_folder_100 = "exp_100_epochs/";
cif_folder_100 = "CIFAR_100_epoch/";
mni_folder_acc = "data_bounded/";
cif_folder_acc = "CIFAR_acc_bound/";
mni_folder_wat = "data_budget/";
cif_folder_wat = "CIFAR_energy_bound/";
mni_folder_est = "early_stop_res/";
cif_folder_est = "CIFAR_early_stop/";
bayes_model = "bayes";
freq_model = "freq";
w_type = "watt";
e_type = "exp";
#=
Load GPU data
=#
mni_100_bay_ene = getgpudata(mni_folder_100, bayes_model, w_type, "eo");
mni_100_fre_ene = getgpudata(mni_folder_100, freq_model, w_type, "eo");
cif_100_bay_ene = getgpudata(cif_folder_100, bayes_model, w_type, "eo");
cif_100_fre_ene = getgpudata(cif_folder_100, freq_model, w_type, "eo");
mni_acc_bay_ene = getgpudata(mni_folder_acc, bayes_model, w_type, "eo");
mni_acc_fre_ene = getgpudata(mni_folder_acc, freq_model, w_type, "eo");
cif_acc_bay_ene = getgpudata(cif_folder_acc, bayes_model, w_type, "eo");
cif_acc_fre_ene = getgpudata(cif_folder_acc, freq_model, w_type, "eo");
mni_wat_bay_ene = getgpudata(mni_folder_wat, bayes_model, w_type, "eo");
mni_wat_fre_ene = getgpudata(mni_folder_wat, freq_model, w_type, "eo");
cif_wat_bay_ene = getgpudata(cif_folder_wat, bayes_model, w_type, "eo");
cif_wat_fre_ene = getgpudata(cif_folder_wat, freq_model, w_type, "eo");
mni_est_bay_ene = getgpudata(mni_folder_est, bayes_model, w_type, "eo");
mni_est_fre_ene = getgpudata(mni_folder_est, freq_model, w_type, "eo");
cif_est_bay_ene = getgpudata(cif_folder_est, bayes_model, w_type, "eo");
cif_est_fre_ene = getgpudata(cif_folder_est, freq_model, w_type, "eo");
#=
Define CPU paths
=#
cif = "cifar";
mni = "mnist";
bay = "bayes";
wat = "cpu_watts";
frq = "freq";
ram = "ram_use";
_100 = "100";
acc = "acc";
es = "es";
wbud = "wbud";
#=
Load CPU data
=#
bay_cif_100_ene = readcpudata(cif, bay, wat, _100);
bay_mni_100_ene = readcpudata(mni, bay, wat, _100);
frq_cif_100_ene = readcpudata(cif, frq, wat, _100);
frq_mni_100_ene = readcpudata(mni, frq, wat, _100);
bay_cif_acc_ene = readcpudata(cif, bay, wat, acc);
bay_mni_acc_ene = readcpudata(mni, bay, wat, acc);
frq_cif_acc_ene = readcpudata(cif, frq, wat, acc);
frq_mni_acc_ene = readcpudata(mni, frq, wat, acc);
bay_cif_wbu_ene = readcpudata(cif, bay, wat, wbud);
bay_mni_wbu_ene = readcpudata(mni, bay, wat, wbud);
frq_cif_wbu_ene = readcpudata(cif, frq, wat, wbud);
frq_mni_wbu_ene = readcpudata(mni, frq, wat, wbud);
bay_mni_est_ene = readcpudata(mni, bay, wat, es);
bay_cif_est_ene = readcpudata(cif, bay, wat, es);
frq_cif_est_ene = readcpudata(cif, frq, wat, es);
frq_mni_est_ene = readcpudata(mni, frq, wat, es);
for s = 1:5
bay_cif_acc_ene[s] = round.(getcpuwatt(bay_cif_acc_ene[s]))
bay_cif_est_ene[s] = round.(getcpuwatt(bay_cif_est_ene[s]))
bay_cif_wbu_ene[s] = round.(getcpuwatt(bay_cif_wbu_ene[s]))
bay_cif_100_ene[s] = round.(getcpuwatt(bay_cif_100_ene[s]))
bay_mni_acc_ene[s] = round.(getcpuwatt(bay_mni_acc_ene[s]))
bay_mni_est_ene[s] = round.(getcpuwatt(bay_mni_est_ene[s]))
bay_mni_wbu_ene[s] = round.(getcpuwatt(bay_mni_wbu_ene[s]))
bay_mni_100_ene[s] = round.(getcpuwatt(bay_mni_100_ene[s]))
frq_cif_acc_ene[s] = round.(getcpuwatt(frq_cif_acc_ene[s]))
frq_cif_est_ene[s] = round.(getcpuwatt(frq_cif_est_ene[s]))
frq_cif_wbu_ene[s] = round.(getcpuwatt(frq_cif_wbu_ene[s]))
frq_cif_100_ene[s] = round.(getcpuwatt(frq_cif_100_ene[s]))
frq_mni_acc_ene[s] = round.(getcpuwatt(frq_mni_acc_ene[s]))
frq_mni_est_ene[s] = round.(getcpuwatt(frq_mni_est_ene[s]))
frq_mni_wbu_ene[s] = round.(getcpuwatt(frq_mni_wbu_ene[s]))
frq_mni_100_ene[s] = round.(getcpuwatt(frq_mni_100_ene[s]))
end
for s = 1:5
mni_100_bay_ene[s]["Ene"] = vcat(mni_100_bay_ene[s]["Ene"], bay_mni_100_ene[s])
mni_100_fre_ene[s]["Ene"] = vcat(mni_100_fre_ene[s]["Ene"], frq_mni_100_ene[s])
cif_100_bay_ene[s]["Ene"] = vcat(cif_100_bay_ene[s]["Ene"], bay_cif_100_ene[s])
cif_100_fre_ene[s]["Ene"] = vcat(cif_100_fre_ene[s]["Ene"], frq_cif_100_ene[s])
mni_acc_bay_ene[s]["Ene"] = vcat(mni_acc_bay_ene[s]["Ene"], bay_mni_acc_ene[s])
mni_acc_fre_ene[s]["Ene"] = vcat(mni_acc_fre_ene[s]["Ene"], frq_mni_acc_ene[s])
cif_acc_bay_ene[s]["Ene"] = vcat(cif_acc_bay_ene[s]["Ene"], bay_cif_acc_ene[s])
cif_acc_fre_ene[s]["Ene"] = vcat(cif_acc_fre_ene[s]["Ene"], frq_cif_acc_ene[s])
mni_wat_bay_ene[s]["Ene"] = vcat(mni_wat_bay_ene[s]["Ene"], bay_mni_wbu_ene[s])
mni_wat_fre_ene[s]["Ene"] = vcat(mni_wat_fre_ene[s]["Ene"], frq_mni_wbu_ene[s])
cif_wat_bay_ene[s]["Ene"] = vcat(cif_wat_bay_ene[s]["Ene"], bay_cif_wbu_ene[s])
cif_wat_fre_ene[s]["Ene"] = vcat(cif_wat_fre_ene[s]["Ene"], frq_cif_wbu_ene[s])
mni_est_bay_ene[s]["Ene"] = vcat(mni_est_bay_ene[s]["Ene"], bay_mni_est_ene[s])
mni_est_fre_ene[s]["Ene"] = vcat(mni_est_fre_ene[s]["Ene"], frq_mni_est_ene[s])
cif_est_bay_ene[s]["Ene"] = vcat(cif_est_bay_ene[s]["Ene"], bay_cif_est_ene[s])
cif_est_fre_ene[s]["Ene"] = vcat(cif_est_fre_ene[s]["Ene"], frq_cif_est_ene[s])
end
mnist_freq_100_ene = zeros(5)
mnist_freq_est_ene = zeros(5)
mnist_freq_wat_ene = zeros(5)
mnist_freq_acc_ene = zeros(5)
mnist_baye_100_ene = zeros(5)
mnist_baye_est_ene = zeros(5)
mnist_baye_wat_ene = zeros(5)
mnist_baye_acc_ene = zeros(5)
cifar_freq_100_ene = zeros(5)
cifar_freq_est_ene = zeros(5)
cifar_freq_wat_ene = zeros(5)
cifar_freq_acc_ene = zeros(5)
cifar_baye_100_ene = zeros(5)
cifar_baye_est_ene = zeros(5)
cifar_baye_wat_ene = zeros(5)
cifar_baye_acc_ene = zeros(5)
for s = 1:5
mnist_baye_100_ene[s] = sum(mni_100_bay_ene[s]["Ene"])
mnist_freq_100_ene[s] = sum(mni_100_fre_ene[s]["Ene"])
cifar_baye_100_ene[s] = sum(cif_100_bay_ene[s]["Ene"])
cifar_freq_100_ene[s] = sum(cif_100_fre_ene[s]["Ene"])
mnist_baye_acc_ene[s] = sum(mni_acc_bay_ene[s]["Ene"])
mnist_freq_acc_ene[s] = sum(mni_acc_fre_ene[s]["Ene"])
cifar_baye_acc_ene[s] = sum(cif_acc_bay_ene[s]["Ene"])
cifar_freq_acc_ene[s] = sum(cif_acc_fre_ene[s]["Ene"])
mnist_baye_wat_ene[s] = sum(mni_wat_bay_ene[s]["Ene"])
mnist_freq_wat_ene[s] = sum(mni_wat_fre_ene[s]["Ene"])
cifar_baye_wat_ene[s] = sum(cif_wat_bay_ene[s]["Ene"])
cifar_freq_wat_ene[s] = sum(cif_wat_fre_ene[s]["Ene"])
mnist_baye_est_ene[s] = sum(mni_est_bay_ene[s]["Ene"])
mnist_freq_est_ene[s] = sum(mni_est_fre_ene[s]["Ene"])
cifar_baye_est_ene[s] = sum(cif_est_bay_ene[s]["Ene"])
cifar_freq_est_ene[s] = sum(cif_est_fre_ene[s]["Ene"])
end
#=
Load Accuracy data
=#
mni_100_bay_exp = getgpudata(mni_folder_100, bayes_model, e_type, "eo");
mni_100_fre_exp = getgpudata(mni_folder_100, freq_model, e_type, "eo");
cif_100_bay_exp = getgpudata(cif_folder_100, bayes_model, e_type, "eo");
cif_100_fre_exp = getgpudata(cif_folder_100, freq_model, e_type, "eo");
mni_acc_bay_exp = getgpudata(mni_folder_acc, bayes_model, e_type, "eo");
mni_acc_fre_exp = getgpudata(mni_folder_acc, freq_model, e_type, "eo");
cif_acc_bay_exp = getgpudata(cif_folder_acc, bayes_model, e_type, "eo");
cif_acc_fre_exp = getgpudata(cif_folder_acc, freq_model, e_type, "eo");
mni_wat_bay_exp = getgpudata(mni_folder_wat, bayes_model, e_type, "eo");
mni_wat_fre_exp = getgpudata(mni_folder_wat, freq_model, e_type, "eo");
cif_wat_bay_exp = getgpudata(cif_folder_wat, bayes_model, e_type, "eo");
cif_wat_fre_exp = getgpudata(cif_folder_wat, freq_model, e_type, "eo");
mni_est_bay_exp = getgpudata(mni_folder_est, bayes_model, e_type, "eo");
mni_est_fre_exp = getgpudata(mni_folder_est, freq_model, e_type, "eo");
cif_est_bay_exp = getgpudata(cif_folder_est, bayes_model, e_type, "eo");
cif_est_fre_exp = getgpudata(cif_folder_est, freq_model, e_type, "eo");
for i = 1:5
mni_100_bay_exp[i] = expdatatodict(mni_100_bay_exp[i])
mni_100_fre_exp[i] = expdatatodict(mni_100_fre_exp[i])
cif_100_bay_exp[i] = expdatatodict(cif_100_bay_exp[i])
cif_100_fre_exp[i] = expdatatodict(cif_100_fre_exp[i])
mni_acc_bay_exp[i] = expdatatodict(mni_acc_bay_exp[i])
mni_acc_fre_exp[i] = expdatatodict(mni_acc_fre_exp[i])
cif_acc_bay_exp[i] = expdatatodict(cif_acc_bay_exp[i])
cif_acc_fre_exp[i] = expdatatodict(cif_acc_fre_exp[i])
mni_wat_bay_exp[i] = expdatatodict(mni_wat_bay_exp[i])
mni_wat_fre_exp[i] = expdatatodict(mni_wat_fre_exp[i])
cif_wat_bay_exp[i] = expdatatodict(cif_wat_bay_exp[i])
cif_wat_fre_exp[i] = expdatatodict(cif_wat_fre_exp[i])
mni_est_bay_exp[i] = expdatatodict(mni_est_bay_exp[i])
mni_est_fre_exp[i] = expdatatodict(mni_est_fre_exp[i])
cif_est_bay_exp[i] = expdatatodict(cif_est_bay_exp[i])
cif_est_fre_exp[i] = expdatatodict(cif_est_fre_exp[i])
end
mnist_freq_100_exp = zeros(5)
mnist_freq_est_exp = zeros(5)
mnist_freq_wat_exp = zeros(5)
mnist_freq_acc_exp = zeros(5)
mnist_baye_100_exp = zeros(5)
mnist_baye_est_exp = zeros(5)
mnist_baye_wat_exp = zeros(5)
mnist_baye_acc_exp = zeros(5)
cifar_freq_100_exp = zeros(5)
cifar_freq_est_exp = zeros(5)
cifar_freq_wat_exp = zeros(5)
cifar_freq_acc_exp = zeros(5)
cifar_baye_100_exp = zeros(5)
cifar_baye_est_exp = zeros(5)
cifar_baye_wat_exp = zeros(5)
cifar_baye_acc_exp = zeros(5)
for s = 1:5
mnist_baye_100_exp[s] = (mean(mni_100_bay_exp[s]["acc"]) + mean(mni_100_bay_exp[s]["pre"])) / 2
mnist_freq_100_exp[s] = (mean(mni_100_fre_exp[s]["acc"]) + mean(mni_100_fre_exp[s]["pre"])) / 2
cifar_baye_100_exp[s] = (mean(cif_100_bay_exp[s]["acc"]) + mean(cif_100_bay_exp[s]["pre"])) / 2
cifar_freq_100_exp[s] = (mean(cif_100_fre_exp[s]["acc"]) + mean(cif_100_fre_exp[s]["pre"])) / 2
mnist_baye_acc_exp[s] = (mean(mni_acc_bay_exp[s]["acc"]) + mean(mni_acc_bay_exp[s]["pre"])) / 2
mnist_freq_acc_exp[s] = (mean(mni_acc_fre_exp[s]["acc"]) + mean(mni_acc_fre_exp[s]["pre"])) / 2
cifar_baye_acc_exp[s] = (mean(cif_acc_bay_exp[s]["acc"]) + mean(cif_acc_bay_exp[s]["pre"])) / 2
cifar_freq_acc_exp[s] = (mean(cif_acc_fre_exp[s]["acc"]) + mean(cif_acc_fre_exp[s]["pre"])) / 2
mnist_baye_wat_exp[s] = (mean(mni_wat_bay_exp[s]["acc"]) + mean(mni_wat_bay_exp[s]["pre"])) / 2
mnist_freq_wat_exp[s] = (mean(mni_wat_fre_exp[s]["acc"]) + mean(mni_wat_fre_exp[s]["pre"])) / 2
cifar_baye_wat_exp[s] = (mean(cif_wat_bay_exp[s]["acc"]) + mean(cif_wat_bay_exp[s]["pre"])) / 2
cifar_freq_wat_exp[s] = (mean(cif_wat_fre_exp[s]["acc"]) + mean(cif_wat_fre_exp[s]["pre"])) / 2
mnist_baye_est_exp[s] = (mean(mni_est_bay_exp[s]["acc"]) + mean(mni_est_bay_exp[s]["pre"])) / 2
mnist_freq_est_exp[s] = (mean(mni_est_fre_exp[s]["acc"]) + mean(mni_est_fre_exp[s]["pre"])) / 2
cifar_baye_est_exp[s] = (mean(cif_est_bay_exp[s]["acc"]) + mean(cif_est_bay_exp[s]["pre"])) / 2
cifar_freq_est_exp[s] = (mean(cif_est_fre_exp[s]["acc"]) + mean(cif_est_fre_exp[s]["pre"])) / 2
end
all_data_exp = Dict(
"mni" => Dict(
1 => Dict(
"100" => Dict("bay" => 0.0, "frq" => 0.0),
"acc" => Dict("bay" => 0.0, "frq" => 0.0),
"wat" => Dict("bay" => 0.0, "frq" => 0.0),
"est" => Dict("bay" => 0.0, "frq" => 0.0),
),
2 => Dict(
"100" => Dict("bay" => 0.0, "frq" => 0.0),
"acc" => Dict("bay" => 0.0, "frq" => 0.0),
"wat" => Dict("bay" => 0.0, "frq" => 0.0),
"est" => Dict("bay" => 0.0, "frq" => 0.0),
),
3 => Dict(
"100" => Dict("bay" => 0.0, "frq" => 0.0),
"acc" => Dict("bay" => 0.0, "frq" => 0.0),
"wat" => Dict("bay" => 0.0, "frq" => 0.0),
"est" => Dict("bay" => 0.0, "frq" => 0.0),
),
4 => Dict(
"100" => Dict("bay" => 0.0, "frq" => 0.0),
"acc" => Dict("bay" => 0.0, "frq" => 0.0),
"wat" => Dict("bay" => 0.0, "frq" => 0.0),
"est" => Dict("bay" => 0.0, "frq" => 0.0),
),
5 => Dict(
"100" => Dict("bay" => 0.0, "frq" => 0.0),
"acc" => Dict("bay" => 0.0, "frq" => 0.0),
"wat" => Dict("bay" => 0.0, "frq" => 0.0),
"est" => Dict("bay" => 0.0, "frq" => 0.0),
),
),
"cif" => Dict(
1 => Dict(
"100" => Dict("bay" => 0.0, "frq" => 0.0),
"acc" => Dict("bay" => 0.0, "frq" => 0.0),
"wat" => Dict("bay" => 0.0, "frq" => 0.0),
"est" => Dict("bay" => 0.0, "frq" => 0.0),
),
2 => Dict(
"100" => Dict("bay" => 0.0, "frq" => 0.0),
"acc" => Dict("bay" => 0.0, "frq" => 0.0),
"wat" => Dict("bay" => 0.0, "frq" => 0.0),
"est" => Dict("bay" => 0.0, "frq" => 0.0),
),
3 => Dict(
"100" => Dict("bay" => 0.0, "frq" => 0.0),
"acc" => Dict("bay" => 0.0, "frq" => 0.0),
"wat" => Dict("bay" => 0.0, "frq" => 0.0),
"est" => Dict("bay" => 0.0, "frq" => 0.0),
),
4 => Dict(
"100" => Dict("bay" => 0.0, "frq" => 0.0),
"acc" => Dict("bay" => 0.0, "frq" => 0.0),
"wat" => Dict("bay" => 0.0, "frq" => 0.0),
"est" => Dict("bay" => 0.0, "frq" => 0.0),
),
5 => Dict(
"100" => Dict("bay" => 0.0, "frq" => 0.0),
"acc" => Dict("bay" => 0.0, "frq" => 0.0),
"wat" => Dict("bay" => 0.0, "frq" => 0.0),
"est" => Dict("bay" => 0.0, "frq" => 0.0),
),
),
)
mnist_freq_100_df = DataFrame(Accuracy=mnist_freq_100_exp,Energy=mnist_freq_100_ene)
mnist_freq_est_df = DataFrame(Accuracy=mnist_freq_est_exp,Energy=mnist_freq_est_ene)
mnist_freq_wat_df = DataFrame(Accuracy=mnist_freq_wat_exp,Energy=mnist_freq_wat_ene)
mnist_freq_acc_df = DataFrame(Accuracy=mnist_freq_acc_exp,Energy=mnist_freq_acc_ene)
mnist_baye_100_df = DataFrame(Accuracy=mnist_baye_100_exp,Energy=mnist_baye_100_ene)
mnist_baye_est_df = DataFrame(Accuracy=mnist_baye_est_exp,Energy=mnist_baye_est_ene)
mnist_baye_wat_df = DataFrame(Accuracy=mnist_baye_wat_exp,Energy=mnist_baye_wat_ene)
mnist_baye_acc_df = DataFrame(Accuracy=mnist_baye_acc_exp,Energy=mnist_baye_acc_ene)
cifar_freq_100_df = DataFrame(Accuracy=cifar_freq_100_exp,Energy=cifar_freq_100_ene)
cifar_freq_est_df = DataFrame(Accuracy=cifar_freq_est_exp,Energy=cifar_freq_est_ene)
cifar_freq_wat_df = DataFrame(Accuracy=cifar_freq_wat_exp,Energy=cifar_freq_wat_ene)
cifar_freq_acc_df = DataFrame(Accuracy=cifar_freq_acc_exp,Energy=cifar_freq_acc_ene)
cifar_baye_100_df = DataFrame(Accuracy=cifar_baye_100_exp,Energy=cifar_baye_100_ene)
cifar_baye_est_df = DataFrame(Accuracy=cifar_baye_est_exp,Energy=cifar_baye_est_ene)
cifar_baye_wat_df = DataFrame(Accuracy=cifar_baye_wat_exp,Energy=cifar_baye_wat_ene)
cifar_baye_acc_df = DataFrame(Accuracy=cifar_baye_acc_exp,Energy=cifar_baye_acc_ene)
println("MNIST 100 Stopping")
latexify(mnist_baye_100_df,env=:table) |> print
latexify(mnist_freq_100_df,env=:table) |> print
println("CIFAR 100 Stopping")
latexify(cifar_baye_100_df,env=:table) |> print
latexify(cifar_freq_100_df,env=:table) |> print
println("MNIST Early Stopping")
latexify(mnist_baye_est_df,env=:table) |> print
latexify(mnist_freq_est_df,env=:table) |> print
println("CIFAR Early Stopping")
latexify(cifar_baye_est_df,env=:table) |> print
latexify(cifar_freq_est_df,env=:table) |> print
println("MNIST Energy bound")
latexify(mnist_baye_wat_df,env=:table) |> print
latexify(mnist_freq_wat_df,env=:table) |> print
println("CIFAR Energy bound")
latexify(cifar_baye_wat_df,env=:table) |> print
latexify(cifar_freq_wat_df,env=:table) |> print
println("MNIST Accuracy bound")
latexify(mnist_baye_acc_df,env=:table) |> print
latexify(mnist_freq_acc_df,env=:table) |> print
println("CIFAR Accuracy bound")
latexify(cifar_baye_acc_df,env=:table) |> print
latexify(cifar_freq_acc_df,env=:table) |> print