bayesiancnn-data-parsing/metric_supreme_graph_50_acc.jl

456 lines
16 KiB
Julia
Raw Normal View History

2024-05-10 10:18:47 +00:00
include("aux_func.jl")
using PlotlyJS: savefig
using Statistics
using PlotlyJS
using Random
#=
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");
#=
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);
for s = 1:5
bay_cif_100_ene[s] = round.(getcpuwatt(bay_cif_100_ene[s]))
bay_mni_100_ene[s] = round.(getcpuwatt(bay_mni_100_ene[s]))
frq_cif_100_ene[s] = round.(getcpuwatt(frq_cif_100_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])
end
ene_data = Dict("mni" => Dict("bay" => Dict(1 => [],2 => [],3 => [],4 => [],5 => []),
"fre" => Dict(1 => [],2 => [],3 => [],4 => [],5 => [])),
"cif" => Dict("bay" => Dict(1 => [],2 => [],3 => [],4 => [],5 => []),
"fre" => Dict(1 => [],2 => [],3 => [],4 => [],5 => [])))
#ene_data = Dict("mni" => Dict("bay" => Dict(1 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0),
# "fre" => Dict(1 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0)),
# "cif" => Dict("bay" => Dict(1 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0),
# "fre" => Dict(1 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0)))
for s = 1:5
ene_data["mni"]["bay"][s] = sum.(join_vectors(resize1(makechunks(shuffle(mni_100_bay_ene[s]["Ene"]), 100))[1:50]))
ene_data["mni"]["fre"][s] = sum.(join_vectors(resize1(makechunks(shuffle(mni_100_fre_ene[s]["Ene"]), 100))[1:50]))
ene_data["cif"]["bay"][s] = sum.(join_vectors(resize1(makechunks(shuffle(cif_100_bay_ene[s]["Ene"]), 100))[1:50]))
ene_data["cif"]["fre"][s] = sum.(join_vectors(resize1(makechunks(shuffle(cif_100_fre_ene[s]["Ene"]), 100))[1:50]))
end
#for s = 1:5
# ene_data["mni"]["bay"][s] = sum(mni_100_bay_ene[s]["Ene"]) / 100
# ene_data["mni"]["fre"][s] = sum(mni_100_fre_ene[s]["Ene"]) / 100
# ene_data["cif"]["bay"][s] = sum(cif_100_bay_ene[s]["Ene"]) / 100
# ene_data["cif"]["fre"][s] = sum(cif_100_fre_ene[s]["Ene"]) / 100
#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");
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])
end
original_vectors_acc = Dict("LeNet" => Dict("MNIST" => Dict(1 => [],2 => [],3 => [],4 => [],5 => []),
"CIFAR" => Dict(1 => [],2 => [],3 => [],4 => [],5 => [])),
"BCNN" => Dict("MNIST" => Dict(1 => [],2 => [],3 => [],4 => [],5 => []),
"CIFAR" => Dict(1 => [],2 => [],3 => [],4 => [],5 => [])))
for i in 1:5
original_vectors_acc["LeNet"]["MNIST"][i] = mni_100_fre_exp[i]["acc"][1:50]
original_vectors_acc["BCNN"]["MNIST"][i] = mni_100_bay_exp[i]["acc"][1:50]
original_vectors_acc["LeNet"]["CIFAR"][i] = cif_100_fre_exp[i]["acc"][1:50]
original_vectors_acc["BCNN"]["CIFAR"][i] = cif_100_bay_exp[i]["acc"][1:50]
end
en_plot = plot(
[
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["LeNet"]["MNIST"][1],
name = "LeNet 1",
marker = attr(symbol = 4, color = "rgb(211,120,000)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["LeNet"]["MNIST"][2],
name = "LeNet 2",
marker = attr(symbol = 17, color = "rgb(255,170,017)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["LeNet"]["MNIST"][3],
name = "LeNet 3",
marker = attr(symbol = 2, color = "rgb(255,187,034)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["LeNet"]["MNIST"][4],
name = "LeNet 4",
marker = attr(symbol = 0, color = "rgb(255,204,051)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["LeNet"]["MNIST"][5],
name = "LeNet 5",
marker = attr(symbol = 4, color = "rgb(255,195,001)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["BCNN"]["MNIST"][1],
name = "BCNN 1",
marker = attr(symbol = 4, color = "rgb(055,033,240)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["BCNN"]["MNIST"][2],
name = "BCNN 2",
marker = attr(symbol = 4, color = "rgb(018,094,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["BCNN"]["MNIST"][3],
name = "BCNN 3",
marker = attr(symbol = 4, color = "rgb(018,126,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["BCNN"]["MNIST"][4],
name = "BCNN 4",
marker = attr(symbol = 4, color = "rgb(018,150,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["BCNN"]["MNIST"][5],
name = "BCNN 5",
marker = attr(symbol = 4, color = "rgb(018,167,219)", line_width = 1.0),
),
],
Layout(
mode = "overlay",
xaxis_tickangle = -45,
yaxis_title_text = "Efficency",
xaxis_title_text = "Epoch";
opacity = 0.9,
#xaxis_range = [-1, 5],
yaxis_range = [0, 1],
#xaxis_type = "category",
),
)
savefig(en_plot, "mnist_50_tacc.png")
en_plot = plot(
[
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["LeNet"]["CIFAR"][1],
name = "LeNet 1",
marker = attr(symbol = 4, color = "rgb(211,120,000)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["LeNet"]["CIFAR"][2],
name = "LeNet 2",
marker = attr(symbol = 17, color = "rgb(255,170,017)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["LeNet"]["CIFAR"][3],
name = "LeNet 3",
marker = attr(symbol = 2, color = "rgb(255,187,034)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["LeNet"]["CIFAR"][4],
name = "LeNet 4",
marker = attr(symbol = 0, color = "rgb(255,204,051)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["LeNet"]["CIFAR"][5],
name = "LeNet 5",
marker = attr(symbol = 4, color = "rgb(255,195,001)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["BCNN"]["CIFAR"][1],
name = "BCNN 1",
marker = attr(symbol = 4, color = "rgb(055,033,240)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["BCNN"]["CIFAR"][2],
name = "BCNN 2",
marker = attr(symbol = 4, color = "rgb(018,094,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["BCNN"]["CIFAR"][3],
name = "BCNN 3",
marker = attr(symbol = 4, color = "rgb(018,126,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["BCNN"]["CIFAR"][4],
name = "BCNN 4",
marker = attr(symbol = 4, color = "rgb(018,150,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_acc["BCNN"]["CIFAR"][5],
name = "BCNN 5",
marker = attr(symbol = 4, color = "rgb(018,167,219)", line_width = 1.0),
),
],
Layout(
mode = "overlay",
xaxis_tickangle = -45,
yaxis_title_text = "Efficency",
xaxis_title_text = "Epoch";
opacity = 0.9,
#xaxis_range = [-1, 5],
yaxis_range = [0, 1],
#xaxis_type = "category",
),
)
savefig(en_plot, "cifar_50_tacc.png")
original_vectors_pre = Dict("LeNet" => Dict("MNIST" => Dict(1 => [],2 => [],3 => [],4 => [],5 => []),
"CIFAR" => Dict(1 => [],2 => [],3 => [],4 => [],5 => [])),
"BCNN" => Dict("MNIST" => Dict(1 => [],2 => [],3 => [],4 => [],5 => []),
"CIFAR" => Dict(1 => [],2 => [],3 => [],4 => [],5 => [])))
for i in 1:5
original_vectors_pre["LeNet"]["MNIST"][i] = mni_100_fre_exp[i]["pre"][1:50]
original_vectors_pre["BCNN"]["MNIST"][i] = mni_100_bay_exp[i]["pre"][1:50]
original_vectors_pre["LeNet"]["CIFAR"][i] = cif_100_fre_exp[i]["pre"][1:50]
original_vectors_pre["BCNN"]["CIFAR"][i] = cif_100_bay_exp[i]["pre"][1:50]
end
en_plot = plot(
[
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["LeNet"]["MNIST"][1],
name = "LeNet 1",
marker = attr(symbol = 4, color = "rgb(211,120,000)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["LeNet"]["MNIST"][2],
name = "LeNet 2",
marker = attr(symbol = 17, color = "rgb(255,170,017)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["LeNet"]["MNIST"][3],
name = "LeNet 3",
marker = attr(symbol = 2, color = "rgb(255,187,034)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["LeNet"]["MNIST"][4],
name = "LeNet 4",
marker = attr(symbol = 0, color = "rgb(255,204,051)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["LeNet"]["MNIST"][5],
name = "LeNet 5",
marker = attr(symbol = 4, color = "rgb(255,195,001)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["BCNN"]["MNIST"][1],
name = "BCNN 1",
marker = attr(symbol = 4, color = "rgb(055,033,240)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["BCNN"]["MNIST"][2],
name = "BCNN 2",
marker = attr(symbol = 4, color = "rgb(018,094,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["BCNN"]["MNIST"][3],
name = "BCNN 3",
marker = attr(symbol = 4, color = "rgb(018,126,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["BCNN"]["MNIST"][4],
name = "BCNN 4",
marker = attr(symbol = 4, color = "rgb(018,150,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["BCNN"]["MNIST"][5],
name = "BCNN 5",
marker = attr(symbol = 4, color = "rgb(018,167,219)", line_width = 1.0),
),
],
Layout(
mode = "overlay",
xaxis_tickangle = -45,
yaxis_title_text = "Efficency",
xaxis_title_text = "Epoch";
opacity = 0.9,
#xaxis_range = [-1, 5],
yaxis_range = [0, 1],
#xaxis_type = "category",
),
)
savefig(en_plot, "mnist_50_tpre.png")
en_plot = plot(
[
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["LeNet"]["CIFAR"][1],
name = "LeNet 1",
marker = attr(symbol = 4, color = "rgb(211,120,000)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["LeNet"]["CIFAR"][2],
name = "LeNet 2",
marker = attr(symbol = 17, color = "rgb(255,170,017)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["LeNet"]["CIFAR"][3],
name = "LeNet 3",
marker = attr(symbol = 2, color = "rgb(255,187,034)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["LeNet"]["CIFAR"][4],
name = "LeNet 4",
marker = attr(symbol = 0, color = "rgb(255,204,051)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["LeNet"]["CIFAR"][5],
name = "LeNet 5",
marker = attr(symbol = 4, color = "rgb(255,195,001)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["BCNN"]["CIFAR"][1],
name = "BCNN 1",
marker = attr(symbol = 4, color = "rgb(055,033,240)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["BCNN"]["CIFAR"][2],
name = "BCNN 2",
marker = attr(symbol = 4, color = "rgb(018,094,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["BCNN"]["CIFAR"][3],
name = "BCNN 3",
marker = attr(symbol = 4, color = "rgb(018,126,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["BCNN"]["CIFAR"][4],
name = "BCNN 4",
marker = attr(symbol = 4, color = "rgb(018,150,219)", line_width = 1.0),
),
scatter(
#x = ["1", "2", "3", "4", "5"],
y = original_vectors_pre["BCNN"]["CIFAR"][5],
name = "BCNN 5",
marker = attr(symbol = 4, color = "rgb(018,167,219)", line_width = 1.0),
),
],
Layout(
mode = "overlay",
xaxis_tickangle = -45,
yaxis_title_text = "Efficency",
xaxis_title_text = "Epoch";
opacity = 0.9,
#xaxis_range = [-1, 5],
yaxis_range = [0, 1],
#xaxis_type = "category",
),
)
savefig(en_plot, "cifar_50_tpre.png")