include("aux_func.jl") using LinearAlgebra using Statistics using PlotlyJS #= 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 all_data_ene = 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), ), ), ) for s = 1:5 all_data_ene["mni"][s]["100"]["bay"] = sum(mni_100_bay_ene[s]["Ene"]) all_data_ene["mni"][s]["100"]["frq"] = sum(mni_100_fre_ene[s]["Ene"]) all_data_ene["cif"][s]["100"]["bay"] = sum(cif_100_bay_ene[s]["Ene"]) all_data_ene["cif"][s]["100"]["frq"] = sum(cif_100_fre_ene[s]["Ene"]) all_data_ene["mni"][s]["acc"]["bay"] = sum(mni_acc_bay_ene[s]["Ene"]) all_data_ene["mni"][s]["acc"]["frq"] = sum(mni_acc_fre_ene[s]["Ene"]) all_data_ene["cif"][s]["acc"]["bay"] = sum(cif_acc_bay_ene[s]["Ene"]) all_data_ene["cif"][s]["acc"]["frq"] = sum(cif_acc_fre_ene[s]["Ene"]) all_data_ene["mni"][s]["wat"]["bay"] = sum(mni_wat_bay_ene[s]["Ene"]) all_data_ene["mni"][s]["wat"]["frq"] = sum(mni_wat_fre_ene[s]["Ene"]) all_data_ene["cif"][s]["wat"]["bay"] = sum(cif_wat_bay_ene[s]["Ene"]) all_data_ene["cif"][s]["wat"]["frq"] = sum(cif_wat_fre_ene[s]["Ene"]) all_data_ene["mni"][s]["est"]["bay"] = sum(mni_est_bay_ene[s]["Ene"]) all_data_ene["mni"][s]["est"]["frq"] = sum(mni_est_fre_ene[s]["Ene"]) all_data_ene["cif"][s]["est"]["bay"] = sum(cif_est_bay_ene[s]["Ene"]) all_data_ene["cif"][s]["est"]["frq"] = sum(cif_est_fre_ene[s]["Ene"]) end #= # sums =# println( "MNIST LeNet 100, Total Energy: [$(all_data_ene["mni"][1]["100"]["frq"]),$(all_data_ene["mni"][2]["100"]["frq"]),$(all_data_ene["mni"][3]["100"]["frq"]),$(all_data_ene["mni"][4]["100"]["frq"]),$(all_data_ene["mni"][5]["100"]["frq"])]", ) println( "MNIST Bayes 100, Total Energy: [$(all_data_ene["mni"][1]["100"]["bay"]),$(all_data_ene["mni"][2]["100"]["bay"]),$(all_data_ene["mni"][3]["100"]["bay"]),$(all_data_ene["mni"][4]["100"]["bay"]),$(all_data_ene["mni"][5]["100"]["bay"])]", ) println( "CIFAR LeNet 100, Total Energy: [$(all_data_ene["cif"][1]["100"]["frq"]),$(all_data_ene["cif"][2]["100"]["frq"]),$(all_data_ene["cif"][3]["100"]["frq"]),$(all_data_ene["cif"][4]["100"]["frq"]),$(all_data_ene["cif"][5]["100"]["frq"])]", ) println( "CIFAR Bayes 100, Total Energy: [$(all_data_ene["cif"][1]["100"]["bay"]),$(all_data_ene["cif"][2]["100"]["bay"]),$(all_data_ene["cif"][3]["100"]["bay"]),$(all_data_ene["cif"][4]["100"]["bay"]),$(all_data_ene["cif"][5]["100"]["bay"])]", ) println( "MNIST LeNet Acc, Total Energy: [$(all_data_ene["mni"][1]["acc"]["frq"]),$(all_data_ene["cif"][2]["acc"]["frq"]),$(all_data_ene["cif"][3]["acc"]["frq"]),$(all_data_ene["cif"][4]["100"]["frq"]),$(all_data_ene["cif"][5]["acc"]["frq"])]", ) println( "MNIST Bayes Acc, Total Energy: [$(all_data_ene["mni"][1]["acc"]["bay"]),$(all_data_ene["cif"][2]["acc"]["bay"]),$(all_data_ene["cif"][3]["acc"]["bay"]),$(all_data_ene["cif"][4]["100"]["bay"]),$(all_data_ene["cif"][5]["acc"]["bay"])]", ) println( "CIFAR LeNet Acc, Total Energy: [$(all_data_ene["cif"][1]["acc"]["frq"]),$(all_data_ene["cif"][2]["acc"]["frq"]),$(all_data_ene["cif"][3]["acc"]["frq"]),$(all_data_ene["cif"][4]["100"]["frq"]),$(all_data_ene["cif"][5]["acc"]["frq"])]", ) println( "CIFAR Bayes Acc, Total Energy: [$(all_data_ene["cif"][1]["acc"]["bay"]),$(all_data_ene["cif"][2]["acc"]["bay"]),$(all_data_ene["cif"][3]["acc"]["bay"]),$(all_data_ene["cif"][4]["100"]["bay"]),$(all_data_ene["cif"][5]["acc"]["bay"])]", ) println( "MNIST LeNet Wat, Total Energy: [$(all_data_ene["mni"][1]["wat"]["frq"]),$(all_data_ene["cif"][2]["wat"]["frq"]),$(all_data_ene["cif"][3]["wat"]["frq"]),$(all_data_ene["cif"][4]["wat"]["frq"]),$(all_data_ene["cif"][5]["wat"]["frq"])]", ) println( "MNIST Bayes Wat, Total Energy: [$(all_data_ene["mni"][1]["wat"]["bay"]),$(all_data_ene["cif"][2]["wat"]["bay"]),$(all_data_ene["cif"][3]["wat"]["bay"]),$(all_data_ene["cif"][4]["wat"]["bay"]),$(all_data_ene["cif"][5]["wat"]["bay"])]", ) println( "CIFAR LeNet Wat, Total Energy: [$(all_data_ene["cif"][1]["wat"]["frq"]),$(all_data_ene["cif"][2]["wat"]["frq"]),$(all_data_ene["cif"][3]["wat"]["frq"]),$(all_data_ene["cif"][4]["wat"]["frq"]),$(all_data_ene["cif"][5]["wat"]["frq"])]", ) println( "CIFAR Bayes Wat, Total Energy: [$(all_data_ene["cif"][1]["wat"]["bay"]),$(all_data_ene["cif"][2]["wat"]["bay"]),$(all_data_ene["cif"][3]["wat"]["bay"]),$(all_data_ene["cif"][4]["wat"]["bay"]),$(all_data_ene["cif"][5]["wat"]["bay"])]", ) println( "MNIST LeNet Est, Total Energy: [$(all_data_ene["mni"][1]["est"]["frq"]),$(all_data_ene["cif"][2]["est"]["frq"]),$(all_data_ene["cif"][3]["est"]["frq"]),$(all_data_ene["cif"][4]["est"]["frq"]),$(all_data_ene["cif"][5]["est"]["frq"])]", ) println( "MNIST Bayes Est, Total Energy: [$(all_data_ene["mni"][1]["est"]["bay"]),$(all_data_ene["cif"][2]["est"]["bay"]),$(all_data_ene["cif"][3]["est"]["bay"]),$(all_data_ene["cif"][4]["est"]["bay"]),$(all_data_ene["cif"][5]["est"]["bay"])]", ) println( "CIFAR LeNet Est, Total Energy: [$(all_data_ene["cif"][1]["est"]["frq"]),$(all_data_ene["cif"][2]["est"]["frq"]),$(all_data_ene["cif"][3]["est"]["frq"]),$(all_data_ene["cif"][4]["est"]["frq"]),$(all_data_ene["cif"][5]["est"]["frq"])]", ) println( "CIFAR Bayes Est, Total Energy: [$(all_data_ene["cif"][1]["est"]["bay"]),$(all_data_ene["cif"][2]["est"]["bay"]),$(all_data_ene["cif"][3]["est"]["bay"]),$(all_data_ene["cif"][4]["est"]["bay"]),$(all_data_ene["cif"][5]["est"]["bay"])]", )