-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
112 lines (94 loc) · 3.17 KB
/
Makefile
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Run all commands in one shell
.ONESHELL:
# Default target
.DEFAULT_GOAL := help
.PHONY : help
## help: run 'make help" at commandline
help : Makefile
@sed -n 's/^##//p' $<
.PHONY: list
## list: list all targets in the current make file
list:
@LC_ALL=C $(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
# Generic Variables
USR := $(shell whoami | head -c 2)
DT := $(shell date +"%Y%m%d")
# Notes: Since accelerate is not working, I recommend using the following values
# | Model | Batch | CPU | Memory |
# | 1 | 688 | 3 | 96 | (ignore this model going forward)
# | 2 | 240 | 3 | 96 |
# Training parameters
model_idx = 1 2
time_steps = 800
beta_schedule = linear cosine quadratic sigmoid
loss_type = l1 l2 huber
epochs = 500
jei_flag = 1
group_labels = 2
# { 0 | 1 | 2}
lr = 5e-5
im_size = (192, 224)
# {(192, 224) | (96, 112)}
downsampled = 0
# {0 | 1}
batch_size = 240
## ddpm-train: train a model from scratch
ddpm-train:
for model in $(model_idx); do \
for schedule in $(beta_schedule); do \
for loss in $(loss_type); do \
logdir=M$$model\T$(time_steps)$$schedule\L$$loss\G$(group_labels)J$(jei_flag)D$(downsampled)
sbatch --job-name=$$logdir submit.sh python -u scripts/main.py train \
--model_idx $$model \
--time_steps $(time_steps) \
--beta_schedule $$schedule \
--loss_type $$loss \
--logdir $$logdir \
--epochs $(epochs) \
--batch_size $(batch_size) \
--jei_flag $(jei_flag) \
--group_labels $(group_labels) \
--lr $(lr) \
--im_size '$(im_size)' \
--downsample; \
done; \
done; \
done;
## ddpm-resume: resume training
ddpm-resume:
for model in $(model_idx); do \
for schedule in $(beta_schedule); do \
for loss in $(loss_type); do \
logdir=test-M$$model\T$(time_steps)$$schedule\L$$loss\G$(group_labels)J$(jei_flag)D1
sbatch --job-name=$$logdir --open-mode=append submit.sh python -u scripts/main.py resume-train \
/space/calico/1/users/Harsha/ddpm-labels/logs/$$logdir; \
done; \
done; \
done;
## ddpm-sample: generate samples from a trained model
%-sample: model_filter = M2*G2*D0 # other examples: {M2* | M2*G2*D0 | ...}
ddpm-sample:
for model_dir in `ls -d1 -r /space/calico/1/users/Harsha/ddpm-labels/logs/$(model_filter)`; do \
model=`basename $$model_dir`
sbatch --job-name=sample-$$model submit.sh python scripts/plot_samples.py $$model_dir
done;
## ddpm-images-to-pdf: collect all images into a pdf
ddpm-images-to-pdf:
python -c "from scripts.plot_samples import combine_images_to_pdf; combine_images_to_pdf('M2*G2*D0')"
## ddpm-test: test changes to code using fashion-mnist data
# please refer to ddpm-labels/models/model1.py and model2.py for more info
# on how to modify the model parameters to work with fashion mnist data
ddpm-test:
python -u scripts/main.py train \
--model_idx 1 \
--time_steps 30 \
--beta_schedule linear \
--logdir mnist \
--epochs 10 \
--im_size '(28, 28)' \
--debug \
;
## model-summary: print model summary
model-summary:
python ddpm_labels/models/model1.py
python ddpm_labels/models/model2.py