-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathattack_test_glue.sh
51 lines (44 loc) · 1.04 KB
/
attack_test_glue.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
CUDA=2
#MODEL_DIR="Date09051354_dsglue_epochs10_seed46_meta1_clamp0.13"
MODEL_DIR=$1
ATTACK_METHOD="textbugger bertattack textfooler"
#echo"test"
regex() {
[[ $1 =~ $2 ]] && printf '%s\n' "${BASH_REMATCH}"
}
get_task_name() {
if [ "$1" == "glue" ]; then
TASK_NAME="sst2"
else
TASK_NAME="None"
fi
}
#liuyan 0910 20:20
get_num_examples() {
if [ "$1" == "glue" ]; then
NUM_EXAMPLES=872
else
NUM_EXAMPLES=1000
fi
}
regex $MODEL_DIR 'Date([0-9]+)_ds([a-z|_]+)_epochs([0-9]+)_seed([0-9]+)_'
DATASET_NAME=${BASH_REMATCH[2]}
EPOCHS=${BASH_REMATCH[3]}
SEED=${BASH_REMATCH[4]}
get_task_name $DATASET_NAME
#liuyan 0910 20:20
get_num_examples $DATASET_NAME
for am in $ATTACK_METHOD
do
logfile=experiment_result/upper_only_attack/${MODEL_DIR}_${am}.log
nohup python upper_attack.py \
--dataset_name $DATASET_NAME \
--task_name $TASK_NAME \
--epochs $EPOCHS \
--cuda $CUDA \
--modeldir $MODEL_DIR \
--seed $SEED \
--attack_method $am \
--num_examples $NUM_EXAMPLES \
> $logfile 2>&1
done