config.py 6.75 KB
Newer Older
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import copy
import ml_collections as mlc


def model_config(name):
    c = copy.deepcopy(config)
    if(name == "model_3"):
        c.model.template.enabled = False
    elif(name == "model_4"):
        c.model.template.enabled = False
    elif(name == "model_5"):
        c.model.template.enabled = False
    
    return c
15

Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
16
17
18
19
20
21

c_z = mlc.FieldReference(128)
c_m = mlc.FieldReference(256)
c_t = mlc.FieldReference(64)
c_e = mlc.FieldReference(64)
c_s = mlc.FieldReference(384)
22
23
blocks_per_ckpt = mlc.FieldReference(1, field_type=int)
chunk_size = mlc.FieldReference(None, field_type=int)
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
24
25
aux_distogram_bins = mlc.FieldReference(64)

26
27
28
eps = 1e-4
inf = 1e4

Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
config = mlc.ConfigDict({
    "model": {
        "c_z": c_z,
        "c_m": c_m,
        "c_t": c_t,
        "c_e": c_e,
        "c_s": c_s,
        "no_cycles": 4,
        "_mask_trans": False,
        "input_embedder": {
            "tf_dim": 22,
            "msa_dim": 49,
            "c_z": c_z,
            "c_m": c_m,
            "relpos_k": 32,
        },
        "recycling_embedder": {
            "c_z": c_z,
            "c_m": c_m, 
            "min_bin": 3.25,
            "max_bin": 20.75,
            "no_bins": 15,
51
            "inf": inf,#1e8,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
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
        },
        "template": {
            "distogram": {
                "min_bin": 3.25,
                "max_bin": 50.75,
                "no_bins": 39,
            },
            "template_angle_embedder": {
                # DISCREPANCY: c_in is supposed to be 51.
                "c_in": 57,
                "c_out": c_m,
            },
            "template_pair_embedder": {
                "c_in": 88,
                "c_out": c_t,
            },
            "template_pair_stack": {
                "c_t": c_t, 
                # DISCREPANCY: c_hidden_tri_att here is given in the supplement
                # as 64. In the code, it's 16.
                "c_hidden_tri_att": 16, 
                "c_hidden_tri_mul": 64,
                "no_blocks": 2, 
                "no_heads": 4, 
                "pair_transition_n": 2, 
                "dropout_rate": 0.25,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
78
                "blocks_per_ckpt": blocks_per_ckpt,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
79
                "chunk_size": chunk_size,
80
                "inf": inf,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
81
82
83
84
85
86
87
88
89
            },
            "template_pointwise_attention": {
                "c_t": c_t, 
                "c_z": c_z, 
                # DISCREPANCY: c_hidden here is given in the supplement as 64.
                # It's actually 16.
                "c_hidden": 16, 
                "no_heads": 4,
                "chunk_size": chunk_size,
90
                "inf": inf,#1e-9,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
91
            },
92
93
            "inf": inf,
            "eps": eps,#1e-6,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
            "enabled": True,
            "embed_angles": True,
        },
        "extra_msa": {
            "extra_msa_embedder": {
                "c_in": 25,
                "c_out": c_e,
            },
            "extra_msa_stack": {
                "c_m": c_e,
                "c_z": c_z,
                "c_hidden_msa_att": 8,
                "c_hidden_opm": 32,
                "c_hidden_mul": 128,
                "c_hidden_pair_att": 32,
                "no_heads_msa": 8,
                "no_heads_pair": 4,
                "no_blocks": 4,
                "transition_n": 4,
                "msa_dropout": 0.15,
                "pair_dropout": 0.25,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
115
                "blocks_per_ckpt": blocks_per_ckpt,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
116
                "chunk_size": chunk_size,
117
118
                "inf": inf,#1e9,
                "eps": eps,#1e-10,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
119
            },
120
            "enabled": False,#True,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
        },
        "evoformer_stack": {
            "c_m": c_m,
            "c_z": c_z,
            "c_hidden_msa_att": 32,
            "c_hidden_opm": 32,
            "c_hidden_mul": 128,
            "c_hidden_pair_att": 32,
            "c_s": c_s,
            "no_heads_msa": 8,
            "no_heads_pair": 4,
            "no_blocks": 48,
            "transition_n": 4,
            "msa_dropout": 0.15,
            "pair_dropout": 0.25,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
136
            "blocks_per_ckpt": blocks_per_ckpt,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
137
            "chunk_size": chunk_size,
138
139
            "inf": inf,#1e9,
            "eps": eps,#1e-10,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
        },
        "structure_module": {
            "c_s": c_s, 
            "c_z": c_z,
            "c_ipa": 16,
            "c_resnet": 128,
            "no_heads_ipa": 12,
            "no_qk_points": 4,
            "no_v_points": 8,
            "dropout_rate": 0.1,
            "no_blocks": 8,
            "no_transition_layers": 1,
            "no_resnet_blocks": 2,
            "no_angles": 7,
            "trans_scale_factor": 10,
155
156
            "epsilon": eps,#1e-12,
            "inf": inf,#1e5,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
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
        },
        "heads": {
            "lddt": {
                "no_bins": 50,
                "c_in": c_s,
                "c_hidden": 128,
            },
            "distogram": {
                "c_z": c_z,
                "no_bins": aux_distogram_bins,
            },
            "tm_score": {
                "c_z": c_z,
                "no_bins": aux_distogram_bins,
                "enabled": False,
            },
            "masked_msa": {
                "c_m": c_m,
                "c_out": 23,
            },
            "experimentally_resolved": {
                "c_s": c_s,
                "c_out": 37,
            },
        },
    },
    "relax": {
        "max_iterations": 0, # no max
        "tolerance": 2.39,
        "stiffness": 10.0,
        "max_outer_iterations": 20,
        "exclude_residues": [],
    },
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
190
191
192
193
194
    "loss": {
        "distogram": {
            "min_bin": 2.3125, 
            "max_bin": 21.6875, 
            "no_bins": 64, 
195
196
            "eps": eps,#1e-6,
            "weight": 0.,#0.3, 
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
197
198
        },
        "experimentally_resolved": {
199
            "eps": eps,#1e-8,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
200
201
202
203
204
205
206
207
208
            "min_resolution": 0.1,
            "max_resolution": 3.0,
            "weight": 0.,
        },
        "fape": {
            "backbone": { 
                "clamp_distance": 10.,
                "loss_unit_distance": 10.,
                "weight": 0.5,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
209
            },
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
210
211
212
213
            "sidechain": {
                "clamp_distance": 10.,
                "length_scale": 10.,
                "weight": 0.5,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
214
            },
215
            "eps": 1e-4,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
216
217
218
219
220
221
            "weight": 1.0,
        },
        "lddt": {
            "min_resolution": 0.1,
            "max_resolution": 3.0,
            "cutoff": 15.,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
222
            "no_bins": 50,
223
224
            "eps": eps,#1e-10,
            "weight": 0.,#0.01,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
225
226
        },
        "masked_msa": {
227
228
            "eps": eps,#1e-8,
            "weight": 0.,#2.0,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
229
230
231
232
        },
        "supervised_chi": {
            "chi_weight": 0.5,
            "angle_norm_weight": 0.01,
233
234
            "eps": eps,#1e-6,
            "weight": 0.,#1.0,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
235
236
        },
        "violation": {
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
237
238
            "violation_tolerance_factor": 12.0,
            "clash_overlap_tolerance": 1.5,
239
            "eps": eps,#1e-6,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
240
241
            "weight": 0.,
        },
242
        "eps": eps,
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
243
    },
Gustaf Ahdritz's avatar
Gustaf Ahdritz committed
244
})