-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyze_insertion.sh
executable file
·68 lines (53 loc) · 1.35 KB
/
analyze_insertion.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# check the dataset name
if [ "$1" == "" ]; then
echo "Error: specify the dataset, abort."
exit 1
fi
# check the GPU has pinned
if [ "$2" == "" ]; then
echo "Error: specify the GPU to run, abort."
exit 1
fi
# common configurations
DATASET=$1
GPU_NUM=$2
# FashionMNIST
if [ "$DATASET" == "fashion_mnist" ]; then
DATAPTH=""
POISOND="datasets/backdoors/$DATASET"
POISONC="4"
POISONR=(0.01)
POISONS=(1 4 7 10 14)
# [BadNet]
NETWORK="badnet"
NETPATH="models/fashion_mnist/vanilla_badnet_100_80_0.01/best_model.h5"
# unknown case
else
echo "Error: unknown dataset - $1"
exit 1
fi
# ----------------------------------------------------------------
# Run for each model location
# ----------------------------------------------------------------
for each_ratio in ${POISONR[@]}; do
for each_tsize in ${POISONS[@]}; do
# : configure the location where poisons are
comp_pfile=$POISOND"/"$POISONC"_"$each_ratio"_"$each_tsize".pkl"
# : run analysis
echo "python3 analyze_insertion.py \
--pin-gpu=$GPU_NUM \
--dataset=$DATASET \
--datapth=$DATAPTH \
--poisonp=$comp_pfile \
--network=$NETWORK \
--netpath=$NETPATH"
python3 analyze_insertion.py \
--pin-gpu=$GPU_NUM \
--dataset=$DATASET \
--datapth=$DATAPTH \
--poisonp=$comp_pfile \
--network=$NETWORK \
--netpath=$NETPATH
done
done