-
Notifications
You must be signed in to change notification settings - Fork 5
/
finetune-exp1.sh
57 lines (46 loc) · 1.85 KB
/
finetune-exp1.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
if [ -z ${CDR} ]; then CDR='1'; fi
PEAK_LR=0.0001
MAX_EPOCH=40
PATIENCE=40
MAX_SENTENCES=1
UPDATE_FREQ=1
MAX_POSITIONS=256
PREFIX_LEN=5
ITER_NUM=5
LOSS_ENC_S=1
LOSS_DEC_S=1
LOSS_DEC_X=1
SEED=42
MODEL_NAME=pflen${PREFIX_LEN}_iter${ITER_NUM}_loss${LOSS_ENC_S}_${LOSS_DEC_S}_${LOSS_DEC_X}_lr${PEAK_LR}_bsz${MAX_SENTENCES}_seed${SEED}
SABDAB_DATA_DIR=data/finetune/exp1/cdrh${CDR}
PRETRAINED_FILE=checkpoints/pretrained/checkpoint215.pt
SAVE_DIR=checkpoints/exp1-cdrh${CDR}/${MODEL_NAME}
FAIRSEQ_MODELS_DIR=fairseq_models
# training
echo $(which fairseq-train)
fairseq-train --sabdab-data $SABDAB_DATA_DIR \
--user-dir $FAIRSEQ_MODELS_DIR --finetune \
--cdr-type ${CDR} \
--task antibody_generation_task \
--criterion antibody_generation_loss \
--arch antibody_roberta_base \
--finetune-bert-scheme prefix_tuning --pre-seq-len $PREFIX_LEN \
--refine-iteration $ITER_NUM --block_size 8 \
--loss-scale-enc $LOSS_ENC_S --loss-scale-dec-sloss $LOSS_DEC_S --loss-scale-dec-xloss $LOSS_DEC_X \
--optimizer adam --clip-norm 1.0 \
--lr-scheduler fixed --lr $PEAK_LR --force-anneal 1 --lr-shrink 0.95 \
--batch-size $MAX_SENTENCES --update-freq $UPDATE_FREQ --max-positions $MAX_POSITIONS --max-epoch $MAX_EPOCH \
--log-format simple --log-interval 5 \
--valid-subset valid,test --skip-invalid-size-inputs-valid-test \
--save-interval 1 --save-dir $SAVE_DIR \
--finetune-from-model $PRETRAINED_FILE \
--patience $PATIENCE --tensorboard-logdir $SAVE_DIR/tensorboard \
--seed $SEED --num-workers 0
# inference
python inference.py --cdr_type ${CDR} \
--cktpath $SAVE_DIR/checkpoint_best.pt --data_path dataset/exp1/cdrh${CDR} > $SAVE_DIR/test_best.txt
for infer_epoch in {1..40}
do
python inference.py --cdr_type ${CDR} \
--cktpath $SAVE_DIR/checkpoint${infer_epoch}.pt --data_path dataset/exp1/cdrh${CDR} > $SAVE_DIR/test${infer_epoch}.txt
done