Final report revisions
This commit is contained in:
21
examples/pseudocode.py
Normal file
21
examples/pseudocode.py
Normal file
@ -0,0 +1,21 @@
|
||||
model = Net()
|
||||
accuracies = {}
|
||||
|
||||
for filter_name in filters:
|
||||
for epsilon in epsilons:
|
||||
for strength in range(5):
|
||||
correct = 0
|
||||
total = 0
|
||||
|
||||
for data, target in dataset:
|
||||
atk_data = fgsm_attack(data, epsilon)
|
||||
filt_data = filtered(atk_data, filter_name, strength)
|
||||
prediction = model(filt_data)
|
||||
|
||||
total += 1
|
||||
if prediction == target:
|
||||
correct += 1
|
||||
|
||||
accuracies[filter_name][epsilon][strength] = correct/total
|
||||
|
||||
save_json("results.json", accuracies)
|
Reference in New Issue
Block a user