Unverified Commit 9e7baa6e authored by Farhad Ramezanghorbani's avatar Farhad Ramezanghorbani Committed by GitHub
Browse files

Download Built-in model parameters from ASE_ANI (#481)

* download resources from ASE_ANI

* update gitignore

* get resources with request

* fix flke8

* rm svn checkout for resources

* update

* fix flake8
parent e08bb3d5
......@@ -30,6 +30,9 @@ dist
*.swo
/download
/download.tar.xz
/torchani/resources/*.info
/torchani/resources/ani-1ccx_8x
/torchani/resources/ani-2x_8x
*.qdrep
*.qdstrm
*.zip
......
#!/bin/bash
# download the data
wget https://www.dropbox.com/sh/2c8zdqc1hrqsgwy/AAD6l24ngoiFa6DRapF6HPk5a/ -O download.zip
unzip download.zip -d download || [[ $? == 2 ]] # unzip return 2 for dropbox created zip file
......@@ -24,10 +24,12 @@ directly calculate energies or get an ASE calculator. For example:
model0.species_to_tensor(['C', 'H', 'H', 'H', 'H'])
"""
import os
import io
import requests
import zipfile
import torch
from torch import Tensor
from typing import Tuple, Optional
from pkg_resources import resource_filename
from . import neurochem
from .nn import SpeciesConverter, SpeciesEnergies
from .aev import AEVComputer
......@@ -70,11 +72,26 @@ class BuiltinModel(torch.nn.Module):
@staticmethod
def _parse_neurochem_resources(info_file_path):
def get_resource(file_path):
package_name = '.'.join(__name__.split('.')[:-1])
return resource_filename(package_name, 'resources/' + file_path)
info_file = get_resource(info_file_path)
def get_resource(resource_path, file_path):
return os.path.join(resource_path, 'resources/' + file_path)
resource_path = os.path.dirname(__file__)
local_dir = os.path.expanduser('~/.local/torchani')
if not os.path.isfile(get_resource(resource_path, info_file_path)):
if not os.path.isfile(get_resource(local_dir, info_file_path)):
print('Downloading ANI model parameters ...')
resource_res = requests.get("https://www.dropbox.com/sh/otrzul6yuye8uzs/AABuaihE22vtaB_rdrI0r6TUa?dl=1")
resource_zip = zipfile.ZipFile(io.BytesIO(resource_res.content))
try:
resource_zip.extractall(resource_path)
except PermissionError:
resource_zip.extractall(local_dir)
resource_path = local_dir
else:
resource_path = local_dir
info_file = get_resource(resource_path, info_file_path)
with open(info_file) as f:
# const_file: Path to the file with the builtin constants.
......@@ -82,9 +99,9 @@ class BuiltinModel(torch.nn.Module):
# ensemble_prefix: Prefix of the neurochem resource directories.
lines = [x.strip() for x in f.readlines()][:4]
const_file_path, sae_file_path, ensemble_prefix_path, ensemble_size = lines
const_file = get_resource(const_file_path)
sae_file = get_resource(sae_file_path)
ensemble_prefix = get_resource(ensemble_prefix_path)
const_file = get_resource(resource_path, const_file_path)
sae_file = get_resource(resource_path, sae_file_path)
ensemble_prefix = get_resource(resource_path, ensemble_prefix_path)
ensemble_size = int(ensemble_size)
consts = neurochem.Constants(const_file)
return consts, sae_file, ensemble_prefix, ensemble_size
......
ani-1ccx_8x/rHCNO-5.2R_16-3.5A_a4-8.params
ani-1ccx_8x/sae_linfit.dat
ani-1ccx_8x/train
8
TM = 1
Rcr = 5.2000e+00
Rca = 3.5000e+00
EtaR = [1.6000000e+01]
ShfR = [9.0000000e-01,1.1687500e+00,1.4375000e+00,1.7062500e+00,1.9750000e+00,2.2437500e+00,2.5125000e+00,2.7812500e+00,3.0500000e+00,3.3187500e+00,3.5875000e+00,3.8562500e+00,4.1250000e+00,4.3937500e+00,4.6625000e+00,4.9312500e+00]
Zeta = [3.2000000e+01]
ShfZ = [1.9634954e-01,5.8904862e-01,9.8174770e-01,1.3744468e+00,1.7671459e+00,2.1598449e+00,2.5525440e+00,2.9452431e+00]
EtaA = [8.0000000e+00]
ShfA = [9.0000000e-01,1.5500000e+00,2.2000000e+00,2.8500000e+00]
Atyp = [H,C,N,O]
H,0=-0.5991501324919538
C,1=-38.03750806057356
N,2=-54.67448347695333
O,3=-75.16043537275567
This diff is collapsed.
!InputFile for Force Prediction Network
sflparamsfile=rHCNO-5.2R_16-3.5A_a4-8.params
ntwkStoreDir=networks/
atomEnergyFile=sae_linfit.dat
nmax=0! Maximum number of iterations (0 = inf)
tolr=200! Tolerance - early stopping
emult=0.5!Multiplier by eta after tol switch
eta=0.001! Eta -- Learning rate
tcrit=1.0E-6! Eta termination criterion
tmax=0! Maximum time (0 = inf)
tbtchsz=2560
vbtchsz=2560
gpuid=0
ntwshr=0
nkde=2
energy=1
freezelayer=0,2
force=0
fmult=0.0
pbc=0
cmult =0.001
runtype=ANNP_CREATE_HDNN_AND_TRAIN!Create and train a HDN network
network_setup {
inputsize=384;
atom_net H $
layer [
nodes=160;
activation=9;
type=0;
]
layer [
nodes=128;
activation=9;
type=0;
l2norm=1;
l2valu=0.00001;
]
layer [
nodes=96;
activation=9;
type=0;
l2norm=1;
l2valu=0.000001;
]
layer [
nodes=1;
activation=6;
type=0;
]
$
atom_net C $
layer [
nodes=144;
activation=9;
type=0;
]
layer [
nodes=112;
activation=9;
type=0;
l2norm=1;
l2valu=0.00001;
]
layer [
nodes=96;
activation=9;
type=0;
l2norm=1;
l2valu=0.000001;
]
layer [
nodes=1;
activation=6;
type=0;
]
$
atom_net N $
layer [
nodes=128;
activation=9;
type=0;
]
layer [
nodes=112;
activation=9;
type=0;
l2norm=1;
l2valu=0.00001;
]
layer [
nodes=96;
activation=9;
type=0;
l2norm=1;
l2valu=0.000001;
]
layer [
nodes=1;
activation=6;
type=0;
]
$
atom_net O $
layer [
nodes=128;
activation=9;
type=0;
]
layer [
nodes=112;
activation=9;
type=0;
l2norm=1;
l2valu=0.00001;
]
layer [
nodes=96;
activation=9;
type=0;
l2norm=1;
l2valu=0.000001;
]
layer [
nodes=1;
activation=6;
type=0;
]
$
}
adptlrn=OFF ! Adaptive learning (OFF,RMSPROP)
decrate=0.9 !Decay rate of RMSPROP
moment=ADAM! Turn on momentum or nesterov momentum (OFF,CNSTTEMP,TMANNEAL,REGULAR,NESTEROV)
mu=0.99 ! Mu factor for momentum
9l=a9vw<<޽e;&=˼Th<eKRІ=-=AܽjT==b><
=8<KΧ;VCyd
p=xn'<n%X > *<<u$(켭S=oX;n=˄۾<5Kz5_LJW:=P9 ܼ!)3ֳ=ƽ>fʼŐ=H?AX=72M w+p(=;=7#%=<y۽to@qT=WbEq c@7Q۴捋=4.==|EZ=> ?f>.f= dk<Mk<y<Ba=-B썽=5^=r=
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment