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
torchani
Commits
8b9c3d1a
Commit
8b9c3d1a
authored
Jul 03, 2019
by
Gao, Xiang
Committed by
Farhad Ramezanghorbani
Jul 03, 2019
Browse files
Support 0 molecule subsets when loading dataset (#257)
* Support 0 molecule subsets when loading dataset * fix * fix
parent
909935a5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
torchani/utils.py
torchani/utils.py
+8
-5
No files found.
torchani/utils.py
View file @
8b9c3d1a
...
...
@@ -48,14 +48,17 @@ def pad_atomic_properties(atomic_properties, padding_values=defaultdict(lambda:
max_atoms
=
max
(
x
[
anykey
].
shape
[
1
]
for
x
in
atomic_properties
)
padded
=
{
k
:
[]
for
k
in
keys
}
for
p
in
atomic_properties
:
num_molecules
=
max
(
v
.
shape
[
0
]
for
v
in
p
.
values
())
num_molecules
=
1
for
v
in
p
.
values
():
assert
num_molecules
in
{
1
,
v
.
shape
[
0
]},
'Number of molecules in different atomic properties mismatch'
if
v
.
shape
[
0
]
!=
1
:
num_molecules
=
v
.
shape
[
0
]
for
k
,
v
in
p
.
items
():
shape
=
list
(
v
.
shape
)
padatoms
=
max_atoms
-
shape
[
1
]
shape
[
1
]
=
padatoms
padding
=
v
.
new_full
(
shape
,
padding_values
[
k
])
v
=
torch
.
cat
([
v
,
padding
],
dim
=
1
)
if
v
.
shape
[
0
]
<
num_molecules
:
shape
=
list
(
v
.
shape
)
shape
[
0
]
=
num_molecules
v
=
v
.
expand
(
*
shape
)
...
...
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