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
c7f549f4
Unverified
Commit
c7f549f4
authored
Oct 30, 2018
by
Gao, Xiang
Committed by
GitHub
Oct 30, 2018
Browse files
Improve according to codefactor.io (#130)
parent
9719edb1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
11 deletions
+11
-11
README.md
README.md
+2
-0
torchani/aev.py
torchani/aev.py
+4
-3
torchani/data/__init__.py
torchani/data/__init__.py
+1
-1
torchani/ignite.py
torchani/ignite.py
+1
-2
torchani/neurochem/__init__.py
torchani/neurochem/__init__.py
+2
-3
torchani/utils.py
torchani/utils.py
+1
-2
No files found.
README.md
View file @
c7f549f4
# <img src=https://raw.githubusercontent.com/aiqm/torchani/master/logo1.png width=180/> Accurate Neural Network Potential on PyTorch
[

]( https://g.codefresh.io/repositories/aiqm/torchani/builds?filter=trigger:build;branch:master;service:5babc52a8a90dc40a407b05f~torchani)
[

](https://www.codefactor.io/repository/github/aiqm/torchani/overview/master)
[

](https://codecov.io/gh/aiqm/torchani)
TorchANI is a pytorch implementation of ANI. It is currently under alpha release, which means, the API is not stable yet. If you find a bug of TorchANI, or have some feature request, feel free to open an issue on GitHub, or send us a pull request.
...
...
torchani/aev.py
View file @
c7f549f4
...
...
@@ -16,10 +16,10 @@ def default_neighborlist(species, coordinates, cutoff):
"""Default neighborlist computer"""
vec
=
coordinates
.
unsqueeze
(
2
)
-
coordinates
.
unsqueeze
(
1
)
"""S
hape (conformations, atoms, atoms, 3) storing Rij vectors
"""
# vec has
hape (conformations, atoms, atoms, 3) storing Rij vectors
distances
=
vec
.
norm
(
2
,
-
1
)
"""S
hape (conformations, atoms, atoms) storing Rij distances
"""
# distances has s
hape (conformations, atoms, atoms) storing Rij distances
padding_mask
=
(
species
==
-
1
).
unsqueeze
(
1
)
distances
=
distances
.
masked_fill
(
padding_mask
,
math
.
inf
)
...
...
@@ -267,7 +267,8 @@ class AEVComputer(torch.nn.Module):
radial_terms
.
unsqueeze
(
-
2
)
*
mask_r
.
unsqueeze
(
-
1
).
type
(
radial_terms
.
dtype
)
).
sum
(
-
3
)
"""shape (conformations, atoms, present species, radial_length)"""
# present_radial_aevs has shape
# (conformations, atoms, present species, radial_length)
radial_aevs
=
present_radial_aevs
.
flatten
(
start_dim
=
2
)
# assemble angular subaev
...
...
torchani/data/__init__.py
View file @
c7f549f4
...
...
@@ -38,7 +38,7 @@ def split_batch(natoms, species, coordinates):
natoms
=
natoms
.
tolist
()
counts
=
[]
for
i
in
natoms
:
if
len
(
counts
)
==
0
:
if
not
counts
:
counts
.
append
([
i
,
1
])
continue
if
i
==
counts
[
-
1
][
0
]:
...
...
torchani/ignite.py
View file @
c7f549f4
...
...
@@ -91,8 +91,7 @@ def MSELoss(key, per_atom=True):
"""Create MSE loss on the specified key."""
if
per_atom
:
return
PerAtomDictLoss
(
key
,
torch
.
nn
.
MSELoss
(
reduction
=
'none'
))
else
:
return
DictLoss
(
key
,
torch
.
nn
.
MSELoss
())
return
DictLoss
(
key
,
torch
.
nn
.
MSELoss
())
class
TransformedLoss
(
_Loss
):
...
...
torchani/neurochem/__init__.py
View file @
c7f549f4
...
...
@@ -526,10 +526,9 @@ class Trainer:
# There is no plan to support the "L2" settings in
# input file before AdamW get merged into pytorch.
raise
NotImplementedError
(
'L2 not supported yet'
)
l2reg
.
append
((
0.5
*
layer
[
'l2valu'
],
module
))
del
layer
[
'l2norm'
]
del
layer
[
'l2valu'
]
if
l
en
(
layer
)
>
0
:
if
l
ayer
:
raise
ValueError
(
'unrecognized parameter in layer setup'
)
i
=
o
atomic_nets
[
atom_type
]
=
torch
.
nn
.
Sequential
(
*
modules
)
...
...
@@ -549,7 +548,7 @@ class Trainer:
MSELoss
(
'energies'
),
lambda
x
:
0.5
*
(
torch
.
exp
(
2
*
x
)
-
1
)
+
l2
())
if
len
(
params
)
>
0
:
if
params
:
raise
ValueError
(
'unrecognized parameter'
)
self
.
global_epoch
=
0
...
...
torchani/utils.py
View file @
c7f549f4
...
...
@@ -161,8 +161,7 @@ class ChemicalSymbolsToInts:
def
__init__
(
self
,
all_species
):
self
.
rev_species
=
{}
for
i
in
range
(
len
(
all_species
)):
s
=
all_species
[
i
]
for
i
,
s
in
enumerate
(
all_species
):
self
.
rev_species
[
s
]
=
i
def
__call__
(
self
,
species
):
...
...
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