Poster very much in the works. Display results working well
This commit is contained in:
parent
54ed4466bc
commit
b473ddc8e9
@ -1 +0,0 @@
|
|||||||
,sharpe,dhcp-150-250-90-28,28.04.2024 00:39,file:///home/sharpe/.var/app/org.libreoffice.LibreOffice/config/libreoffice/4;
|
|
BIN
20240428_12h59m15s_grim.png
Normal file
BIN
20240428_12h59m15s_grim.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 221 KiB |
BIN
Filter_Analysis/CIFAR-10_FGSM_highest_rank.png
Normal file
BIN
Filter_Analysis/CIFAR-10_FGSM_highest_rank.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
BIN
Filter_Analysis/CIFAR-10_FGSM_performance_map.png
Normal file
BIN
Filter_Analysis/CIFAR-10_FGSM_performance_map.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
BIN
Filter_Analysis/MNIST_FGSM_highest_rank.png
Normal file
BIN
Filter_Analysis/MNIST_FGSM_highest_rank.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
BIN
Filter_Analysis/MNIST_FGSM_performance_map.png
Normal file
BIN
Filter_Analysis/MNIST_FGSM_performance_map.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
59
Filter_Analysis/]
Normal file
59
Filter_Analysis/]
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import json
|
||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from matplotlib import cm
|
||||||
|
import copy
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
data = {}
|
||||||
|
with open("results/cifar10_fgsm.json", "r") as infile:
|
||||||
|
data = json.load(infile)
|
||||||
|
|
||||||
|
attack = data["attack"]
|
||||||
|
epsilons = data["epsilons"]
|
||||||
|
filters = data["filters"]
|
||||||
|
dataset = data["dataset"]
|
||||||
|
strength_count = len(filters[list(filters.keys())[0]][0])
|
||||||
|
|
||||||
|
strengths = np.arange(strength_count)
|
||||||
|
epsilons = np.array(epsilons)
|
||||||
|
|
||||||
|
# Assume constant step of strength and epsilon
|
||||||
|
dstrength = strengths[1] - strengths[0]
|
||||||
|
depsilon = epsilons[1] - epsilons[0]
|
||||||
|
|
||||||
|
# Make a grid from strengths and epsilons
|
||||||
|
strengths, epsilons = np.meshgrid(strengths,epsilons)
|
||||||
|
#strengths, epsilons = strengths.ravel(), epsilons.ravel()
|
||||||
|
|
||||||
|
colors = ('blue', 'orange', 'red', 'purple', 'green', 'yellow', 'brown')
|
||||||
|
|
||||||
|
z = np.zeros_like(strengths)
|
||||||
|
best_performance = np.zeros_like(strengths)
|
||||||
|
bottoms = np.zeros_like(strengths)
|
||||||
|
|
||||||
|
for i, filter in enumerate(filters):
|
||||||
|
performance = np.array(filters[filter])
|
||||||
|
best_performance = np.where(performance > best_performance, i, best_performance)
|
||||||
|
z = np.where(performance > z, performance, z)
|
||||||
|
print(best_performance)
|
||||||
|
|
||||||
|
for i, filter in enumerate(filters):
|
||||||
|
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
|
||||||
|
tops = np.where(best_performance == i, best_performance, 0)
|
||||||
|
print(strengths.shape, epsilons.shape, bottoms.shape, dstrength.shape, depsilon.shape, tops.shape)
|
||||||
|
ax.bar3d(strengths, epsilons, bottoms, dstrength, depsilon, tops, color=colors[i])
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
ax.view_init(90, -90, 0)
|
||||||
|
|
||||||
|
plt.legend()
|
||||||
|
plt.title(f"{filter} Performance")
|
||||||
|
plt.xlabel(f"{attack} Attack Strength ($\\epsilon$)")
|
||||||
|
plt.ylabel(f"{dataset} Classification Accuracy")
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -1,13 +1,18 @@
|
|||||||
import json
|
import json
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
from matplotlib import cm
|
||||||
|
from mpl_toolkits.mplot3d import Axes3D
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
is_rank = False
|
||||||
|
has_random_guessing_threshold = False
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
with open("results/mnist_fgsm.json", "r") as infile:
|
with open("results/cifar10_fgsm.json", "r") as infile:
|
||||||
data = json.load(infile)
|
data = json.load(infile)
|
||||||
|
|
||||||
attack = data["attack"]
|
attack = data["attack"]
|
||||||
@ -16,22 +21,73 @@ def main():
|
|||||||
dataset = data["dataset"]
|
dataset = data["dataset"]
|
||||||
strength_count = len(filters[list(filters.keys())[0]][0])
|
strength_count = len(filters[list(filters.keys())[0]][0])
|
||||||
|
|
||||||
for filter in filters:
|
random_guess_threshold = np.ndarray((len(epsilons), strength_count))
|
||||||
plt.figure(figsize=(16,9))
|
random_guess_threshold.fill(0.1)
|
||||||
for i in range(strength_count):
|
print(random_guess_threshold.shape)
|
||||||
filter_accuracy = [filters[filter][eps][i] for eps in range(len(epsilons))]
|
|
||||||
plt.plot(epsilons, filter_accuracy, label=f"Strength = {i}")
|
|
||||||
|
|
||||||
|
filters["Random Guess Threshold"] = random_guess_threshold
|
||||||
|
|
||||||
# Plot horizontal line at random guessing level
|
strengths = np.arange(strength_count)
|
||||||
plt.hlines(0.1, epsilons[0], epsilons[-1], label="Random Guessing Threshold", colors="black", linestyles="dashed")
|
epsilons = np.array(epsilons)
|
||||||
|
|
||||||
plt.legend(loc="upper right")
|
# Assume constant step of strength and epsilon
|
||||||
plt.title(f"{filter} Performance")
|
dstrength = strengths[1] - strengths[0]
|
||||||
plt.xlabel(f"{attack} Attack Strength ($\\epsilon$)")
|
depsilon = epsilons[1] - epsilons[0]
|
||||||
plt.ylabel(f"{dataset} Classification Accuracy")
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
|
# Make a grid from strengths and epsilons
|
||||||
|
strengths, epsilons = np.meshgrid(strengths,epsilons)
|
||||||
|
|
||||||
|
colors = ('blue', 'orange', 'red', 'purple', 'green', 'yellow', 'brown', 'black')
|
||||||
|
|
||||||
|
z = np.zeros_like(strengths)
|
||||||
|
best_performance = np.zeros_like(strengths)
|
||||||
|
|
||||||
|
strengths, epsilons = strengths.ravel(), epsilons.ravel()
|
||||||
|
|
||||||
|
for i, filter in enumerate(filters):
|
||||||
|
performance = np.array(filters[filter])
|
||||||
|
best_performance = np.where(performance > z, i, best_performance)
|
||||||
|
z = np.where(performance > z, performance, z)
|
||||||
|
|
||||||
|
z = z.ravel()
|
||||||
|
fig, ax = plt.subplots(subplot_kw={"projection": "3d"}, figsize=(9,10))
|
||||||
|
for i, filter in enumerate(filters):
|
||||||
|
if i not in best_performance:
|
||||||
|
continue
|
||||||
|
tops = []
|
||||||
|
x = []
|
||||||
|
y = []
|
||||||
|
for j, best in enumerate(best_performance.ravel()):
|
||||||
|
if best == i:
|
||||||
|
x.append(strengths[j])
|
||||||
|
y.append(epsilons[j])
|
||||||
|
tops.append(z[j])
|
||||||
|
x = np.array(x)
|
||||||
|
y = np.array(y)
|
||||||
|
tops = np.array(tops)
|
||||||
|
greyscale = [((height+0.5)/1.5, 0, 0) if height > 0.1 else 'black' for height in tops]
|
||||||
|
if is_rank:
|
||||||
|
ax.bar3d(x, y, 0, dstrength, depsilon, tops, color=colors[i], zsort="average", shade=True, label=filter)
|
||||||
|
else:
|
||||||
|
if i < len(filters)-1:
|
||||||
|
ax.bar3d(x, y, 0, dstrength, depsilon, tops, color=greyscale, zsort="average", shade=True)
|
||||||
|
else:
|
||||||
|
ax.bar3d(x, y, 0, dstrength, depsilon, tops, color=greyscale, zsort="average", shade=True, label=filter)
|
||||||
|
has_random_guessing_threshold = True
|
||||||
|
|
||||||
|
ax.zaxis.line.set_lw(0.)
|
||||||
|
ax.set_zticks([])
|
||||||
|
ax.view_init(90, 0, 0)
|
||||||
|
ax.set_proj_type('ortho')
|
||||||
|
|
||||||
|
if is_rank or has_random_guessing_threshold:
|
||||||
|
ax.legend(loc="lower center")
|
||||||
|
plt.title(f"{"Highest Rank Filters" if is_rank else "Filter Performance"} for {dataset}")
|
||||||
|
plt.ylabel(f"{attack} Attack Strength ($\\epsilon$)")
|
||||||
|
plt.xlabel("Filter Strength")
|
||||||
|
plt.clabel(f"{dataset} Classification Accuracy")
|
||||||
|
plt.savefig(f"{dataset}_{attack}_{"highest_rank" if is_rank else "performance_map"}.png")
|
||||||
|
#plt.show()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
BIN
Poster.pptx
BIN
Poster.pptx
Binary file not shown.
Loading…
Reference in New Issue
Block a user