forked from hassonlab/247-encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
244 lines (214 loc) · 6.21 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# Non-configurable paramters. Don't touch.
FILE := tfsenc_main
USR := $(shell whoami | head -c 2)
DT := $(shell date +"%Y%m%d-%H%M")
# -----------------------------------------------------------------------------
# Configurable options
# -----------------------------------------------------------------------------
PRJCT_ID := tfs
# {podcast | tfs}
# 625 Electrode IDs
SID := 625
E_LIST := $(shell seq 1 105)
# # 676 Electrode IDs
# SID := 676
# E_LIST := $(shell seq 1 125)
PKL_IDENTIFIER := full
# {full | trimmed}
# podcast electeode IDs
# SID := 661
# E_LIST := $(shell seq 1 115)
# SID := 662
# E_LIST := $(shell seq 1 100)
# SID := 717
# E_LIST := $(shell seq 1 255)
# SID := 723
# E_LIST := $(shell seq 1 165)
# SID := 741
# E_LIST := $(shell seq 1 130)
# SID := 742
# E_LIST := $(shell seq 1 175)
# SID := 743
# E_LIST := $(shell seq 1 125)
# SID := 763
# E_LIST := $(shell seq 1 80)
# SID := 798
# E_LIST := $(shell seq 1 195)
# number of permutations (goes with SH and PSH)
NPERM := 1
# Choose the lags to run for.
LAGS := {-2000..2000..25}
CONVERSATION_IDX := 0
# Choose which set of embeddings to use
EMB := blenderbot-small
# {glove50 | gpt2-xl | blenderbot-small}
CNXT_LEN := 1024
# Choose the window size to average for each point
WS := 200
# Choose which set of embeddings to align with
ALIGN_WITH := gpt2-xl
ALIGN_TGT_CNXT_LEN := 1024
# Specify the minimum word frequency
MWF := 1
# TODO: explain this parameter.
WV := all
# Choose whether to label or phase shuffle
# SH := --shuffle
# PSH := --phase-shuffle
# Choose whether to normalize the embeddings
# NM := l2
# {l1 | l2 | max}
PCA_TO := 50
# Choose the command to run: python runs locally, echo is for debugging, sbatch
# is for running on SLURM all lags in parallel.
CMD := sbatch submit1.sh
# {echo | python | sbatch submit1.sh}
# datum
# DS := podcast-datum-glove-50d.csv
# DS := podcast-datum-gpt2-xl-c_1024-previous-pca_50d.csv
#TODO: move paths to makefile
# plotting modularity
# make separate models with separate electrodes (all at once is possible)
PDIR := $(shell dirname `pwd`)
link-data:
ln -fs $(PDIR)/247-pickling/results/* data/
# -----------------------------------------------------------------------------
# Encoding
# -----------------------------------------------------------------------------
target1:
for elec in $(E_LIST); do \
$(CMD) code/$(FILE).py \
--subject $(SID) \
--lags $(LAGS) \
--emb-file $(EMB) \
--electrode $$elec \
--npermutations
--output-folder $(DT)-$(SID)-test; \
done
# Run the encoding model for the given electrodes in one swoop
# Note that the code will add the subject, embedding type, and PCA details to
# the output folder name
run-encoding:
mkdir -p logs
$(CMD) code/$(FILE).py \
--project-id $(PRJCT_ID) \
--pkl-identifier $(PKL_IDENTIFIER) \
--datum-emb-fn $(DS) \
--sid $(SID) \
--conversation-id $(CONVERSATION_IDX) \
--electrodes $(E_LIST) \
--emb-type $(EMB) \
--context-length $(CNXT_LEN) \
--align-with $(ALIGN_WITH) \
--align-target-context-length $(ALIGN_TGT_CNXT_LEN) \
--window-size $(WS) \
--word-value $(WV) \
--npermutations $(NPERM) \
--lags $(LAGS) \
--min-word-freq $(MWF) \
--pca-to $(PCA_TO) \
$(SH) \
$(PSH) \
--normalize $(NM)\
--output-parent-dir $(DT)-$(PRJCT_ID)-$(PKL_IDENTIFIER)-$(SID)-$(EMB) \
--output-prefix '';\
run-sig-encoding:
mkdir -p logs
$(CMD) code/$(FILE).py \
--project-id $(PRJCT_ID) \
--pkl-identifier $(PKL_IDENTIFIER) \
--datum-emb-fn $(DS) \
--conversation-id $(CONVERSATION_IDX) \
--sig-elec-file bobbi.csv \
--emb-type $(EMB) \
--context-length $(CNXT_LEN) \
--align-with $(ALIGN_WITH) \
--align-target-context-length $(ALIGN_TGT_CNXT_LEN) \
--window-size $(WS) \
--word-value $(WV) \
--npermutations $(NPERM) \
--lags $(LAGS) \
--min-word-freq $(MWF) \
--pca-to $(PCA_TO) \
$(SH) \
$(PSH) \
--normalize $(NM)\
--output-parent-dir sig-elec-test-tfs \
--output-prefix '';\
# Recommended naming convention for output_folder
#--output-prefix $(USR)-$(WS)ms-$(WV); \
# Run the encoding model for the given electrodes __one at a time__, ideally
# with slurm so it's all parallelized.
run-encoding-slurm:
mkdir -p logs
for elec in $(E_LIST); do \
# for jobid in $(shell seq 1 1); do \
$(CMD) code/$(FILE).py \
--project-id $(PRJCT_ID) \
--pkl-identifier $(PKL_IDENTIFIER) \
--sid $(SID) \
--electrodes $$elec \
--conversation-id $(CONVERSATION_IDX) \
--emb-type $(EMB) \
--context-length $(CNXT_LEN) \
--align-with $(ALIGN_WITH) \
--align-target-context-length $(ALIGN_TGT_CNXT_LEN) \
--window-size $(WS) \
--word-value $(WV) \
--npermutations $(NPERM) \
--lags $(LAGS) \
--min-word-freq $(MWF) \
--pca-to $(PCA_TO) \
$(SH) \
$(PSH) \
--normalize $(NM) \
--output-parent-dir $(PRJCT_ID)-$(PKL_IDENTIFIER)-$(EMB)-pca$(PCA_TO) \
--output-prefix ''; \
# --job-id $(EMB)-$$jobid; \
# done; \
done;
run-sig-encoding-slurm:
mkdir -p logs
for elec in $(E_LIST); do \
# for jobid in $(shell seq 1 1); do \
$(CMD) code/$(FILE).py \
--project-id $(PRJCT_ID) \
--pkl-identifier $(PKL_IDENTIFIER) \
--sig-elec-file bobbi.csv \
--emb-type $(EMB) \
--context-length $(CNXT_LEN) \
--align-with $(ALIGN_WITH) \
--align-target-context-length $(ALIGN_TGT_CNXT_LEN) \
--window-size $(WS) \
--word-value $(WV) \
--npermutations $(NPERM) \
--lags $(LAGS) \
--min-word-freq $(MWF) \
--pca-to $(PCA_TO) \
$(SH) \
$(PSH) \
--output-parent-dir podcast-gpt2-xl-transcription \
--output-prefix ''; \
# --job-id $(EMB)-$$jobid; \
# done; \
done;
pca-on-embedding:
python code/tfsenc_pca.py \
--sid $(SID) \
--emb-type $(EMB) \
--context-length $(CNXT_LEN) \
--pca-to $(EMB_RED_DIM);
# -----------------------------------------------------------------------------
# Plotting
# -----------------------------------------------------------------------------
plot-encoding1:
mkdir -p results/figures
python code/tfsenc_plots.py \
--project-id $(PRJCT_ID) \
--sid $(SID) \
--input-directory \
tfs-full-blenderbot-small-pca50 \
--labels \
blenderbot-small \
--output-file-name \
tfs-full-blenderbot-small-pca50;