Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
OpenFold
Commits
0026173e
Commit
0026173e
authored
Oct 22, 2023
by
Sachin Kadyan
Browse files
Cleaned up `precompute_embeddings.py`.
parent
bcc6d97b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
16 deletions
+5
-16
scripts/precompute_embeddings.py
scripts/precompute_embeddings.py
+5
-16
No files found.
scripts/precompute_embeddings.py
View file @
0026173e
...
...
@@ -95,8 +95,7 @@ def main(args):
dataset
,
collate_fn
=
alphabet
.
get_batch_converter
(),
batch_sampler
=
batches
)
logging
.
info
(
"Loaded all sequences"
)
assert
all
(
-
(
model
.
num_layers
+
1
)
<=
i
<=
model
.
num_layers
for
i
in
args
.
repr_layers
)
repr_layers
=
[(
i
+
model
.
num_layers
+
1
)
%
(
model
.
num_layers
+
1
)
for
i
in
args
.
repr_layers
]
repr_layers
=
[
33
]
with
torch
.
no_grad
():
for
batch_idx
,
(
labels
,
strs
,
toks
)
in
enumerate
(
data_loader
):
...
...
@@ -118,7 +117,6 @@ def main(args):
os
.
makedirs
(
os
.
path
.
join
(
args
.
output_dir
,
label
),
exist_ok
=
True
)
result
=
{
"label"
:
label
}
if
"per_tok"
in
args
.
include
:
result
[
"representations"
]
=
{
layer
:
t
[
i
,
1
:
len
(
strs
[
i
])
+
1
].
clone
()
for
layer
,
t
in
representations
.
items
()
...
...
@@ -146,15 +144,6 @@ if __name__ == "__main__":
"--toks_per_batch"
,
type
=
int
,
default
=
4096
,
help
=
"maximum tokens in a batch"
)
parser
.
add_argument
(
"--repr_layers"
,
type
=
int
,
default
=
[
-
1
],
nargs
=
"+"
,
help
=
"Layer indices from which to extract representations (0 to num_layers, inclusive)"
)
parser
.
add_argument
(
"--include"
,
type
=
str
,
default
=
[
"per_tok"
],
nargs
=
"+"
,
choices
=
[
"mean"
,
"per_tok"
,
"bos"
,
"contacts"
],
help
=
"Specify which representations to return"
)
parser
.
add_argument
(
"--truncate"
,
action
=
"store_true"
,
default
=
True
,
help
=
"Truncate sequences longer than 1022 (ESM restriction). Default: True"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment