include("aux_func.jl") using PlotlyJS: savefig using Statistics using PlotlyJS using Random using Printf #= 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:100])) ene_data["mni"]["fre"][s] = sum.(join_vectors(resize1(makechunks(shuffle(mni_100_fre_ene[s]["Ene"]), 100))[1:100])) ene_data["cif"]["bay"][s] = sum.(join_vectors(resize1(makechunks(shuffle(cif_100_bay_ene[s]["Ene"]), 100))[1:100])) ene_data["cif"]["fre"][s] = sum.(join_vectors(resize1(makechunks(shuffle(cif_100_fre_ene[s]["Ene"]), 100))[1:100])) 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 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0), "CIFAR" => Dict(1 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0)), "BCNN" => Dict("MNIST" => Dict(1 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0), "CIFAR" => Dict(1 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0))) for i in 1:5 original_vectors_acc["LeNet"]["MNIST"][i] = mean(mni_100_fre_exp[i]["acc"][1:100]) @printf "LeNet-5 on MNIST acc size %i Metric: %-.8f\n" i original_vectors_acc["LeNet"]["MNIST"][i] original_vectors_acc["BCNN"]["MNIST"][i] = mean(mni_100_bay_exp[i]["acc"][1:100]) @printf "BCNN-5 on MNIST acc size %i Metric: %-.8f\n" i original_vectors_acc["BCNN"]["MNIST"][i] original_vectors_acc["LeNet"]["CIFAR"][i] = mean(cif_100_fre_exp[i]["acc"][1:100]) @printf "LeNet-5 on CIFAR acc size %i Metric: %-.8f\n" i original_vectors_acc["LeNet"]["CIFAR"][i] original_vectors_acc["BCNN"]["CIFAR"][i] = mean(cif_100_bay_exp[i]["acc"][1:100]) @printf "BCNN-5 on CIFAR acc size %i Metric: %-.8f\n" i original_vectors_acc["BCNN"]["CIFAR"][i] end println("\n\n\n") original_vectors_pre = Dict("LeNet" => Dict("MNIST" => Dict(1 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0), "CIFAR" => Dict(1 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0)), "BCNN" => Dict("MNIST" => Dict(1 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0), "CIFAR" => Dict(1 => 0.0,2 => 0.0,3 => 0.0,4 => 0.0,5 => 0.0))) for i in 1:5 original_vectors_pre["LeNet"]["MNIST"][i] = mean(mni_100_fre_exp[i]["pre"][1:100]) @printf "LeNet-5 on MNIST pre size %i Metric: %-.8f\n" i original_vectors_pre["LeNet"]["MNIST"][i] original_vectors_pre["BCNN"]["MNIST"][i] = mean(mni_100_bay_exp[i]["pre"][1:100]) @printf "BCNN-5 on MNIST pre size %i Metric: %-.8f\n" i original_vectors_pre["BCNN"]["MNIST"][i] original_vectors_pre["LeNet"]["CIFAR"][i] = mean(cif_100_fre_exp[i]["pre"][1:100]) @printf "LeNet-5 on CIFAR pre size %i Metric: %-.8f\n" i original_vectors_pre["LeNet"]["CIFAR"][i] original_vectors_pre["BCNN"]["CIFAR"][i] = mean(cif_100_bay_exp[i]["pre"][1:100]) @printf "BCNN-5 on CIFAR pre size %i Metric: %-.8f\n" i original_vectors_pre["BCNN"]["CIFAR"][i] end