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
08a5be86
Commit
08a5be86
authored
Jul 14, 2023
by
Geoffrey Yu
Browse files
update the merge label functions so that the merging dimension is not hard coded
parent
66a60d58
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
10 deletions
+5
-10
openfold/utils/loss.py
openfold/utils/loss.py
+5
-10
No files found.
openfold/utils/loss.py
View file @
08a5be86
...
...
@@ -1893,23 +1893,18 @@ def merge_labels(batch, per_asym_residue_index, labels, align):
cur_out
=
{}
for
i
,
j
in
align
:
label
=
labels
[
j
][
k
]
cur_num_res
=
labels
[
j
][
'aatype'
].
shape
[
-
1
]
# to 1-based
cur_residue_index
=
per_asym_residue_index
[
i
+
1
]
if
len
(
v
.
shape
)
==
0
or
"template"
in
k
:
continue
else
:
cur_out
[
i
]
=
label
[
cur_residue_index
]
dimension_to_merge
=
label
.
shape
.
index
(
cur_num_res
)
if
cur_num_res
in
label
.
shape
else
0
cur_out
[
i
]
=
label
.
index_select
(
dimension_to_merge
,
cur_residue_index
)
cur_out
=
[
x
[
1
]
for
x
in
sorted
(
cur_out
.
items
())]
if
len
(
cur_out
)
>
0
:
new_v
=
torch
.
concat
(
cur_out
,
dim
=
0
)
merged_nres
=
new_v
.
shape
[
0
]
assert
(
merged_nres
<=
num_res
),
f
"bad merged num res:
{
merged_nres
}
>
{
num_res
}
. something is wrong."
if
merged_nres
<
num_res
:
# must pad
pad_dim
=
new_v
.
shape
[
1
:]
pad_v
=
new_v
.
new_zeros
((
num_res
-
merged_nres
,
*
pad_dim
))
new_v
=
torch
.
concat
((
new_v
,
pad_v
),
dim
=
0
)
new_v
=
torch
.
concat
(
cur_out
,
dim
=
dimension_to_merge
)
print
(
f
"k is
{
k
}
shape:
{
label
.
shape
}
and dimension_to_merge:
{
dimension_to_merge
}
"
)
outs
[
k
]
=
new_v
print
(
f
"finished merging"
)
for
k
,
v
in
outs
.
items
():
...
...
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