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
ac27ed3d
Unverified
Commit
ac27ed3d
authored
Jun 11, 2020
by
Gao, Xiang
Committed by
GitHub
Jun 11, 2020
Browse files
Update model URL (#484)
* Update model URL * Update models.py * Update models.py * fix * cleanup * save
parent
9e7baa6e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
examples/energy_force.py
examples/energy_force.py
+1
-1
torchani/models.py
torchani/models.py
+18
-4
No files found.
examples/energy_force.py
View file @
ac27ed3d
...
@@ -26,7 +26,7 @@ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
...
@@ -26,7 +26,7 @@ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# The ``periodic_table_index`` arguments tells TorchANI to use element index
# The ``periodic_table_index`` arguments tells TorchANI to use element index
# in periodic table to index species. If not specified, you need to use
# in periodic table to index species. If not specified, you need to use
# 0, 1, 2, 3, ... to index species
# 0, 1, 2, 3, ... to index species
model
=
torchani
.
models
.
ANI
1cc
x
(
periodic_table_index
=
True
).
to
(
device
)
model
=
torchani
.
models
.
ANI
2
x
(
periodic_table_index
=
True
).
to
(
device
)
###############################################################################
###############################################################################
# Now let's define the coordinate and species. If you just want to compute the
# Now let's define the coordinate and species. If you just want to compute the
...
...
torchani/models.py
View file @
ac27ed3d
...
@@ -26,7 +26,9 @@ directly calculate energies or get an ASE calculator. For example:
...
@@ -26,7 +26,9 @@ directly calculate energies or get an ASE calculator. For example:
import
os
import
os
import
io
import
io
import
requests
import
requests
import
glob
import
zipfile
import
zipfile
import
shutil
import
torch
import
torch
from
torch
import
Tensor
from
torch
import
Tensor
from
typing
import
Tuple
,
Optional
from
typing
import
Tuple
,
Optional
...
@@ -73,15 +75,19 @@ class BuiltinModel(torch.nn.Module):
...
@@ -73,15 +75,19 @@ class BuiltinModel(torch.nn.Module):
@
staticmethod
@
staticmethod
def
_parse_neurochem_resources
(
info_file_path
):
def
_parse_neurochem_resources
(
info_file_path
):
def
get_resource
(
resource_path
,
file_path
):
def
get_resource
(
resource_path
,
file_path
):
return
os
.
path
.
join
(
resource_path
,
'resources/'
+
file_path
)
return
os
.
path
.
join
(
resource_path
,
file_path
)
resource_path
=
os
.
path
.
dirname
(
__file__
)
resource_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'resources/'
)
local_dir
=
os
.
path
.
expanduser
(
'~/.local/torchani'
)
local_dir
=
os
.
path
.
expanduser
(
'~/.local/torchani/'
)
repo_name
=
"ani-model-zoo"
tag_name
=
"ani-2x"
extracted_name
=
'{}-{}'
.
format
(
repo_name
,
tag_name
)
url
=
"https://github.com/aiqm/{}/archive/{}.zip"
.
format
(
repo_name
,
tag_name
)
if
not
os
.
path
.
isfile
(
get_resource
(
resource_path
,
info_file_path
)):
if
not
os
.
path
.
isfile
(
get_resource
(
resource_path
,
info_file_path
)):
if
not
os
.
path
.
isfile
(
get_resource
(
local_dir
,
info_file_path
)):
if
not
os
.
path
.
isfile
(
get_resource
(
local_dir
,
info_file_path
)):
print
(
'Downloading ANI model parameters ...'
)
print
(
'Downloading ANI model parameters ...'
)
resource_res
=
requests
.
get
(
"https://www.dropbox.com/sh/otrzul6yuye8uzs/AABuaihE22vtaB_rdrI0r6TUa?dl=1"
)
resource_res
=
requests
.
get
(
url
)
resource_zip
=
zipfile
.
ZipFile
(
io
.
BytesIO
(
resource_res
.
content
))
resource_zip
=
zipfile
.
ZipFile
(
io
.
BytesIO
(
resource_res
.
content
))
try
:
try
:
resource_zip
.
extractall
(
resource_path
)
resource_zip
.
extractall
(
resource_path
)
...
@@ -91,6 +97,14 @@ class BuiltinModel(torch.nn.Module):
...
@@ -91,6 +97,14 @@ class BuiltinModel(torch.nn.Module):
else
:
else
:
resource_path
=
local_dir
resource_path
=
local_dir
files
=
glob
.
glob
(
os
.
path
.
join
(
resource_path
,
extracted_name
,
"resources"
,
"*"
))
for
f
in
files
:
try
:
shutil
.
move
(
f
,
resource_path
)
except
shutil
.
Error
:
pass
shutil
.
rmtree
(
os
.
path
.
join
(
resource_path
,
extracted_name
))
info_file
=
get_resource
(
resource_path
,
info_file_path
)
info_file
=
get_resource
(
resource_path
,
info_file_path
)
with
open
(
info_file
)
as
f
:
with
open
(
info_file
)
as
f
:
...
...
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