bayesiancnn-data-parsing/bounded.jl

239 lines
7.2 KiB
Julia
Executable File

####################################################
#
# Accuracy is bounded
#
#####################################################
include("aux_func.jl")
using PlotlyJS
using PlotlyJS: savefig
using Statistics
folder = "data_bounded/"
bayes_exp_1 = load_pickle("$(folder)bayes_exp_data_1.pkl");
bayes_exp_2 = load_pickle("$(folder)bayes_exp_data_2.pkl");
bayes_exp_3 = load_pickle("$(folder)bayes_exp_data_3.pkl");
bayes_exp_4 = load_pickle("$(folder)bayes_exp_data_4.pkl");
bayes_exp_5 = load_pickle("$(folder)bayes_exp_data_5.pkl");
b_exp_1_tls = bayes_exp_1[:, 2]
b_exp_1_acc = bayes_exp_1[:, 3]
b_exp_1_vls = bayes_exp_1[:, 4]
b_exp_1_pre = bayes_exp_1[:, 5]
println("Training accuracy bayes 1 $(mean(b_exp_1_acc))")
println("Testing accuracy bayes 1 $(mean(b_exp_1_pre))")
b_exp_2_tls = bayes_exp_2[:, 2]
b_exp_2_acc = bayes_exp_2[:, 3]
b_exp_2_vls = bayes_exp_2[:, 4]
b_exp_2_pre = bayes_exp_2[:, 5]
println("Training accuracy bayes 2 $(mean(b_exp_2_acc))")
println("Testing accuracy bayes 2 $(mean(b_exp_2_pre))")
b_exp_3_tls = bayes_exp_3[:, 2]
b_exp_3_acc = bayes_exp_3[:, 3]
b_exp_3_vls = bayes_exp_3[:, 4]
b_exp_3_pre = bayes_exp_3[:, 5]
println("Training accuracy bayes 3 $(mean(b_exp_3_acc))")
println("Testing accuracy bayes 3 $(mean(b_exp_3_pre))")
b_exp_4_tls = bayes_exp_4[:, 2]
b_exp_4_acc = bayes_exp_4[:, 3]
b_exp_4_vls = bayes_exp_4[:, 4]
b_exp_4_pre = bayes_exp_4[:, 5]
println("Training accuracy bayes 4 $(mean(b_exp_4_acc))")
println("Testing accuracy bayes 4 $(mean(b_exp_4_pre))")
b_exp_5_tls = bayes_exp_5[:, 2]
b_exp_5_acc = bayes_exp_5[:, 3]
b_exp_5_vls = bayes_exp_5[:, 4]
b_exp_5_pre = bayes_exp_5[:, 5]
println("Training accuracy bayes 5 $(mean(b_exp_5_acc))")
println("Testing accuracy bayes 5 $(mean(b_exp_5_pre))")
println("Amount of epochs to reach bound Bayesian 1x: $(size(bayes_exp_1)[1])")
println("Amount of epochs to reach bound Bayesian 2x: $(size(bayes_exp_2)[1])")
println("Amount of epochs to reach bound Bayesian 3x: $(size(bayes_exp_3)[1])")
println("Amount of epochs to reach bound Bayesian 4x: $(size(bayes_exp_4)[1])")
println("Amount of epochs to reach bound Bayesian 5x: $(size(bayes_exp_5)[1])")
freq_exp_1 = load_pickle("$(folder)freq_exp_data_1.pkl");
freq_exp_2 = load_pickle("$(folder)freq_exp_data_2.pkl");
freq_exp_3 = load_pickle("$(folder)freq_exp_data_3.pkl");
freq_exp_4 = load_pickle("$(folder)freq_exp_data_4.pkl");
freq_exp_5 = load_pickle("$(folder)freq_exp_data_5.pkl");
f_exp_1_tls = freq_exp_1[:, 2]
f_exp_1_acc = freq_exp_1[:, 3]
f_exp_1_vls = freq_exp_1[:, 4]
f_exp_1_pre = freq_exp_1[:, 5]
println("Training accuracy freq 1 $(mean(f_exp_1_acc))")
println("Testing accuracy freq 1 $(mean(f_exp_1_pre))")
f_exp_2_tls = freq_exp_2[:, 2]
f_exp_2_acc = freq_exp_2[:, 3]
f_exp_2_vls = freq_exp_2[:, 4]
f_exp_2_pre = freq_exp_2[:, 5]
println("Training accuracy freq 2 $(mean(f_exp_2_acc))")
println("Testing accuracy freq 2 $(mean(f_exp_2_pre))")
f_exp_3_tls = freq_exp_3[:, 2]
f_exp_3_acc = freq_exp_3[:, 3]
f_exp_3_vls = freq_exp_3[:, 4]
f_exp_3_pre = freq_exp_3[:, 5]
println("Training accuracy freq 3 $(mean(f_exp_3_acc))")
println("Testing accuracy freq 3 $(mean(f_exp_3_pre))")
f_exp_4_tls = freq_exp_4[:, 2]
f_exp_4_acc = freq_exp_4[:, 3]
f_exp_4_vls = freq_exp_4[:, 4]
f_exp_4_pre = freq_exp_4[:, 5]
println("Training accuracy freq 4 $(mean(f_exp_4_acc))")
println("Testing accuracy freq 4 $(mean(f_exp_4_pre))")
f_exp_5_tls = freq_exp_5[:, 2]
f_exp_5_acc = freq_exp_5[:, 3]
f_exp_5_vls = freq_exp_5[:, 4]
f_exp_5_pre = freq_exp_5[:, 5]
println("Training accuracy freq 5 $(mean(f_exp_5_acc))")
println("Testing accuracy freq 5 $(mean(f_exp_5_pre))")
println("Amount of epochs to reach bound LeNet 1x: $(size(freq_exp_1)[1])")
println("Amount of epochs to reach bound LeNet 2x: $(size(freq_exp_2)[1])")
println("Amount of epochs to reach bound LeNet 3x: $(size(freq_exp_3)[1])")
println("Amount of epochs to reach bound LeNet 4x: $(size(freq_exp_4)[1])")
println("Amount of epochs to reach bound LeNet 5x: $(size(freq_exp_5)[1])")
en_plot = plot(
[
scatter(
y = f_exp_1_acc,
name = "LeNet 1",
marker = attr(color = "rgb(211,120,000)"),
),
scatter(
y = f_exp_2_acc,
name = "LeNet 2",
marker = attr(color = "rgb(255,170,017)"),
),
scatter(
y = f_exp_3_acc,
name = "LeNet 3",
marker = attr(color = "rgb(255,187,034)"),
),
scatter(
y = f_exp_4_acc,
name = "LeNet 4",
marker = attr(color = "rgb(255,204,051)"),
),
scatter(
y = f_exp_5_acc,
name = "LeNet 5",
marker = attr(color = "rgb(255,221,068)"),
),
scatter(
y = b_exp_1_acc,
name = "BCNN 1",
marker = attr(color = "rgb(055,033,240)"),
),
scatter(
y = b_exp_2_acc,
name = "BCNN 2",
marker = attr(color = "rgb(033,081,240)"),
),
scatter(
y = b_exp_3_acc,
name = "BCNN 3",
marker = attr(color = "rgb(033,115,240)"),
),
scatter(
y = b_exp_4_acc,
name = "BCNN 4",
marker = attr(color = "rgb(151,177,255)"),
),
scatter(
y = b_exp_5_acc,
name = "BCNN 5",
marker = attr(color = "rgb(051,215,255)"),
),
],
Layout(
mode = "lines",
opacity = 0.4,
xaxis_tickangle = -45,
yaxis_title_text = "Accuracy",
xaxis_title_text = "Epoch";
yaxis_range = [0, 1],
),
)
savefig(en_plot, "mnist_ab_tacc.png")
en_plot = plot(
[
scatter(
y = f_exp_1_pre,
name = "LeNet 1",
marker = attr(color = "rgb(211,120,000)"),
),
scatter(
y = f_exp_2_pre,
name = "LeNet 2",
marker = attr(color = "rgb(255,170,017)"),
),
scatter(
y = f_exp_3_pre,
name = "LeNet 3",
marker = attr(color = "rgb(255,187,034)"),
),
scatter(
y = f_exp_4_pre,
name = "LeNet 4",
marker = attr(color = "rgb(255,204,051)"),
),
scatter(
y = f_exp_5_pre,
name = "LeNet 5",
marker = attr(color = "rgb(255,221,068)"),
),
scatter(
y = b_exp_1_pre,
name = "BCNN 1",
marker = attr(color = "rgb(055,033,240)"),
),
scatter(
y = b_exp_2_pre,
name = "BCNN 2",
marker = attr(color = "rgb(033,081,240)"),
),
scatter(
y = b_exp_3_pre,
name = "BCNN 3",
marker = attr(color = "rgb(033,115,240)"),
),
scatter(
y = b_exp_4_pre,
name = "BCNN 4",
marker = attr(color = "rgb(151,177,255)"),
),
scatter(
y = b_exp_5_pre,
name = "BCNN 5",
marker = attr(color = "rgb(051,215,255)"),
),
],
Layout(
mode = "lines",
opacity = 0.4,
xaxis_tickangle = -45,
yaxis_title_text = "Accuracy",
xaxis_title_text = "Epoch";
yaxis_range = [0, 1],
),
)
savefig(en_plot, "mnist_ab_tpre.png")