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
74221a98
Unverified
Commit
74221a98
authored
Jan 16, 2019
by
Gao, Xiang
Committed by
GitHub
Jan 16, 2019
Browse files
Use torch.combinations (#116)
parent
391a672c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
9 deletions
+1
-9
torchani/aev.py
torchani/aev.py
+1
-9
No files found.
torchani/aev.py
View file @
74221a98
...
@@ -210,19 +210,11 @@ class AEVComputer(torch.nn.Module):
...
@@ -210,19 +210,11 @@ class AEVComputer(torch.nn.Module):
return
radial_terms
,
angular_terms
,
species_
return
radial_terms
,
angular_terms
,
species_
def
_combinations
(
self
,
tensor
,
dim
=
0
):
def
_combinations
(
self
,
tensor
,
dim
=
0
):
# TODO: remove this when combinations is merged into PyTorch
# https://github.com/pytorch/pytorch/pull/9393
n
=
tensor
.
shape
[
dim
]
n
=
tensor
.
shape
[
dim
]
if
n
==
0
:
if
n
==
0
:
return
tensor
,
tensor
return
tensor
,
tensor
r
=
torch
.
arange
(
n
,
dtype
=
torch
.
long
,
device
=
tensor
.
device
)
r
=
torch
.
arange
(
n
,
dtype
=
torch
.
long
,
device
=
tensor
.
device
)
grid_x
,
grid_y
=
torch
.
meshgrid
([
r
,
r
])
index1
,
index2
=
torch
.
combinations
(
r
).
unbind
(
-
1
)
index1
=
grid_y
.
masked_select
(
torch
.
triu
(
torch
.
ones
(
n
,
n
,
device
=
tensor
.
device
),
diagonal
=
1
)
==
1
)
index2
=
grid_x
.
masked_select
(
torch
.
triu
(
torch
.
ones
(
n
,
n
,
device
=
tensor
.
device
),
diagonal
=
1
)
==
1
)
return
tensor
.
index_select
(
dim
,
index1
),
\
return
tensor
.
index_select
(
dim
,
index1
),
\
tensor
.
index_select
(
dim
,
index2
)
tensor
.
index_select
(
dim
,
index2
)
...
...
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