#using HDF5 include("aux_func.jl") #using Plots #using StatsPlots using Statistics using LinearAlgebra using PlotlyJS, Random, StatsBase using PlotlyJS: savefig folder = "ini_exp_data/" #fcnn = h5open("fcnn_watt_data.h5", "r") do file # read(file,"fcnn") #end #bcnn = h5open("bcnn_watt_data.h5", "r") do file # read(file,"bcnn") #end fcnn = load_pickle("$(folder)fcnn_wattdata.pkl") bcnn = load_pickle("$(folder)bcnn_wattdata.pkl") bcnn_w = removewatt(bcnn[:, 1]) mem_bcnn = removewatt(bcnn[:, 3]) #bcnn_ch = bcnn_w .> 28 #bcnn_start = findall(x -> x==1, bcnn_ch)[1] #bcnn_end = findall(x -> x==1, bcnn_ch)[end] #bcnn_w_tot = bcnn_w[bcnn_start:bcnn_end] #bcnn_tot = sum(bcnn_w_tot) #mean_bcnn_w = mean(bcnn_w_tot) #bcnn_s = size(bcnn_w_tot)[1] #mean_bcnn_w_v = mean_bcnn_w .* ones(bcnn_s) #x_bcnn = collect(1:bcnn_s) fcnn_w = removewatt(fcnn[:, 1]) mem_fcnn = removewatt(fcnn[:, 3]) #val_ch = fcnn_w .> 28 #fcnn_start = findall(x -> x==1, val_ch)[1] #fcnn_end = findall(x -> x==1, val_ch)[end] #fcnn_w_tot = fcnn_w[fcnn_start:fcnn_end] #fcnn_tot = sum(fcnn_w_tot) #mean_fcnn_w = mean(fcnn_w_tot) #fcnn_s = size(fcnn_w_tot)[1] #mean_fcnn_w_v = mean_fcnn_w .* ones(fcnn_s) #x_fcnn = collect(1:fcnn_s) mem_bcnn = parse.(Int64, replace.(bcnn[:, 3], r"[^0-9]+" => "")) mem_fcnn = parse.(Int64, replace.(fcnn[:, 3], r"[^0-9]+" => "")) #en_plot = boxplot(bcnn_w_tot,x_bcnn,title="Energy per sample",xlabel="Watts",ylabel="No of samples",label="BCNN",seriesalpha=0.5) #boxplot!(fcnn_w_tot,x_fcnn,label="CNN",seriesalpha=0.5,color="green") #savefig(en_plot,"energy.png") #en_plot = histogram(bcnn_w,xlabel="Watts",ylabel="No of samples",label="BCNN",color="blue",normalize=:pdf,bar_position = :overlay) #histogram!(fcnn_w,label="LeNet",seriesalpha=0.9,color="#ff9900",normalize=:pdf,bar_position=:overlay) #savefig(en_plot,"energy.png") #bcnn_w = incwzeros(bcnn_w,length(fcnn_w)-length(bcnn_w)) #bcnn_w = reshape(bcnn_w,:,1) #fcnn_w = reshape(fcnn_w,:,1) #w_mat = hcat(bcnn_w,fcnn_w) #groupedbar(rand(length(bcnn_w),2),bar_width=0.5,bar_position = :dodge) #w_mat = reshape(w_mat,2,:) #mem_plot = plot(mem_fcnn,title="Memory usage, one epoch in MiB's",label="CNN Memory",lw=2,seriesalpha=0.5) #plot!(mem_bcnn,label="BCNN Memory",lw=2,seriesalpha=0.5,fmt=:png) #savefig(mem_plot,"memory.png") #mem_plot = histogram(mem_bcnn,xlabel="MiB",ylabel="No of samples",label="BCNN",color="blue") #histogram!(mem_fcnn,label="LeNet",seriesalpha=0.9,color="#ff9900") #savefig(mem_plot,"memory.png") #plot(bcnn_w_tot,title="BCNN energy in one epoch",label="Watt",lw=2);plot!(mean_bcnn_w_v,label="Mean") #plot(fcnn_w_tot,title="CNN energy in one epoch",label="Watt",lw=2);plot!(mean_fcnn_w_v,label="Mean") #scatter(bcnn[1,:],title="Energy usage in W",label="Bayesian CNN",lw=2);scatter!(fcnn[1,1:463],label="CNN",lw=2) bcnn_d = countmap(bcnn_w) bcnn_u = unique(bcnn_w) bcnn_v = Vector() for u in bcnn_u push!(bcnn_v, bcnn_d[u]) end m_bcnn_d = countmap(mem_bcnn) m_bcnn_u = unique(mem_bcnn) m_bcnn_v = Vector() for u in m_bcnn_u push!(m_bcnn_v, m_bcnn_d[u]) end fcnn_d = countmap(fcnn_w) fcnn_u = unique(fcnn_w) fcnn_v = Vector() for u in fcnn_u push!(fcnn_v, fcnn_d[u]) end m_fcnn_d = countmap(mem_fcnn) m_fcnn_u = unique(mem_fcnn) m_fcnn_v = Vector() for u in fcnn_u push!(m_fcnn_v, fcnn_d[u]) end bcnn_v = bcnn_v / norm(bcnn_v) fcnn_v = fcnn_v / norm(fcnn_v) m_bcnn_v = m_bcnn_v / norm(m_bcnn_v) m_fcnn_v = m_fcnn_v / norm(m_fcnn_v) en_plot = plot( [ bar(x = bcnn_u, y = bcnn_v, name = "BCNN", marker_color = "blue"), bar(x = fcnn_u, y = fcnn_v, name = "LeNet", marker_color = "#ff9900"), ], Layout( barmode = "group", xaxis_tickangle = -45, yaxis_title_text = "Samples", xaxis_title_text = "Watts", title = "Energy distribution experiment 1", ), ) savefig(en_plot, "energy.png") mem_plot = plot( [ bar(x = m_bcnn_u, y = m_bcnn_v, name = "BCNN", marker_color = "blue"), bar(x = m_fcnn_u, y = m_fcnn_v, name = "LeNet", marker_color = "#ff9900"), ], Layout( barmode = "group", xaxis_tickangle = -45, yaxis_title_text = "Samples", xaxis_title_text = "MiB", title = "MRW distribution experiment 1", ), ) savefig(mem_plot, "memory.png")