Commit b3c7e0e3 authored by Kevin Ryan's avatar Kevin Ryan Committed by Gao, Xiang
Browse files

Added ANI-1ccx model with a similar loader to Builtins. (#167)



* Added ANI-1ccx model with a similar loader to Builtins.

* Apply suggestions from code review
Co-Authored-By: default avatarLeanAndMean <40122815+LeanAndMean@users.noreply.github.com>

* Fixed linter errors.
parent 74221a98
......@@ -259,8 +259,16 @@ def load_model_ensemble(species, prefix, count):
return Ensemble(models)
class Builtins:
"""Container for all builtin stuffs.
class BuiltinsAbstract:
"""Base class for loading ANI neural network from configuration files.
Arguments:
parent_name (:class:`str`): Base path that other paths are relative to.
const_file_path (:class:`str`): Path to constant file for ANI model(s).
sae_file_path (:class:`str`): Path to sae file for ANI model(s).
ensemble_size (:class:`int`): Number of models in model ensemble.
ensemble_prefix_path (:class:`str`): Path to prefix of directories of
models.
Attributes:
const_file (:class:`str`): Path to the builtin constant file.
......@@ -275,28 +283,96 @@ class Builtins:
ensemble_prefix (:class:`str`): Prefix of directories of models.
models (:class:`torchani.Ensemble`): Ensemble of models.
"""
def __init__(self):
parent_name = '.'.join(__name__.split('.')[:-1])
def __init__(
self,
parent_name,
const_file_path,
sae_file_path,
ensemble_size,
ensemble_prefix_path):
self.const_file = pkg_resources.resource_filename(
parent_name,
'resources/ani-1x_dft_x8ens/rHCNO-5.2R_16-3.5A_a4-8.params')
const_file_path)
self.consts = Constants(self.const_file)
self.species = self.consts.species
self.aev_computer = AEVComputer(**self.consts)
self.sae_file = pkg_resources.resource_filename(
parent_name, 'resources/ani-1x_dft_x8ens/sae_linfit.dat')
parent_name,
sae_file_path)
self.energy_shifter = load_sae(self.sae_file)
self.ensemble_size = 8
self.ensemble_size = ensemble_size
self.ensemble_prefix = pkg_resources.resource_filename(
parent_name, 'resources/ani-1x_dft_x8ens/train')
parent_name,
ensemble_prefix_path)
self.models = load_model_ensemble(self.consts.species,
self.ensemble_prefix,
self.ensemble_size)
class Builtins(BuiltinsAbstract):
"""Container for the builtin ANI-1x model.
Attributes:
const_file (:class:`str`): Path to the builtin constant file.
consts (:class:`Constants`): Constants loaded from builtin constant
file.
aev_computer (:class:`torchani.AEVComputer`): AEV computer with builtin
constants.
sae_file (:class:`str`): Path to the builtin self atomic energy file.
energy_shifter (:class:`torchani.EnergyShifter`): AEV computer with
builtin constants.
ensemble_size (:class:`int`): Number of models in model ensemble.
ensemble_prefix (:class:`str`): Prefix of directories of models.
models (:class:`torchani.Ensemble`): Ensemble of models.
"""
def __init__(self):
parent_name = '.'.join(__name__.split('.')[:-1])
const_file_path = 'resources/ani-1x_dft_x8ens'\
'/rHCNO-5.2R_16-3.5A_a4-8.params'
sae_file_path = 'resources/ani-1x_dft_x8ens/sae_linfit.dat'
ensemble_size = 8
ensemble_prefix_path = 'resources/ani-1x_dft_x8ens/train'
super(Builtins, self).__init__(
parent_name,
const_file_path,
sae_file_path,
ensemble_size,
ensemble_prefix_path
)
class BuiltinsANI1CCX(BuiltinsAbstract):
"""Container for the builtin ANI-1ccx model.
Attributes:
const_file (:class:`str`): Path to the builtin constant file.
consts (:class:`Constants`): Constants loaded from builtin constant
file.
aev_computer (:class:`torchani.AEVComputer`): AEV computer with builtin
constants.
sae_file (:class:`str`): Path to the builtin self atomic energy file.
energy_shifter (:class:`torchani.EnergyShifter`): AEV computer with
builtin constants.
ensemble_size (:class:`int`): Number of models in model ensemble.
ensemble_prefix (:class:`str`): Prefix of directories of models.
models (:class:`torchani.Ensemble`): Ensemble of models.
"""
def __init__(self):
parent_name = '.'.join(__name__.split('.')[:-1])
const_file_path = 'resources/ani-1ccx_8x'\
'/rHCNO-5.2R_16-3.5A_a4-8.params'
sae_file_path = 'resources/ani-1ccx_8x/sae_linfit.dat'
ensemble_size = 8
ensemble_prefix_path = 'resources/ani-1ccx_8x/train'
super(BuiltinsANI1CCX, self).__init__(
parent_name,
const_file_path,
sae_file_path,
ensemble_size,
ensemble_prefix_path
)
def hartree2kcal(x):
return 627.509 * x
......
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;
l2norm=1;
l2valu=0.0001;
]
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;
l2norm=1;
l2valu=0.0001;
]
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;
l2norm=1;
l2valu=0.0001;
]
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;
l2norm=1;
l2valu=0.0001;
]
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