from peslearn.ml import NeuralNetwork from peslearn import InputProcessor import torch import numpy as np from itertools import combinations nn = NeuralNetwork('PES.dat', InputProcessor(''), molecule_type='A2B') params = {'layers': (16,), 'morse_transform': {'morse': False}, 'pip': {'degree_reduction': True, 'pip': True}, 'scale_X': {'activation': 'tanh', 'scale_X': 'mm11'}, 'scale_y': 'mm11', 'lr': 0.5} X, y, Xscaler, yscaler = nn.preprocess(params, nn.raw_X, nn.raw_y) model = torch.load('model.pt') # How to use 'compute_energy()' function # -------------------------------------- # E = compute_energy(geom_vectors, cartesian=bool) # 'geom_vectors' is either: # 1. A list or tuple of coordinates for a single geometry. # 2. A column vector of one or more sets of 1d coordinate vectors as a list of lists or 2D NumPy array: # [[ coord1, coord2, ..., coordn], # [ coord1, coord2, ..., coordn], # : : : ], # [ coord1, coord2, ..., coordn]] # In all cases, coordinates should be supplied in the exact same format and exact same order the model was trained on. # If the coordinates format used to train the model was interatomic distances, each set of coordinates should be a 1d array of either interatom distances or cartesian coordinates. # If cartesian coordinates are supplied, cartesian=True should be passed and it will convert them to interatomic distances. # The order of coordinates matters. If PES-Learn datasets were used they should be in standard order; # i.e. cartesians should be supplied in the order x,y,z of most common atoms first, with alphabetical tiebreaker. # e.g., C2H3O2 --> H1x H1y H1z H2x H2y H2z H3x H3y H3z C1x C1y C1z C2x C2y C2z O1x O1y O1z O2x O2y O2z # and interatom distances should be the row-wise order of the lower triangle of the interatom distance matrix, with standard order atom axes: # H H H C C O O # H
from peslearn.ml import GaussianProcess from peslearn import InputProcessor from GPy.core.model import Model import numpy as np import json from itertools import combinations gp = GaussianProcess('PES.dat', InputProcessor(''), molecule_type='A2B') params = { 'morse_transform': { 'morse': True, 'morse_alpha': 1.6 }, 'pip': { 'degree_reduction': False, 'pip': True }, 'scale_X': 'mm01', 'scale_y': 'std' } X, y, Xscaler, yscaler = gp.preprocess(params, gp.raw_X, gp.raw_y) model = Model('mymodel') with open('model.json', 'r') as f: model_dict = json.load(f) final = model.from_dict(model_dict) # How to use 'compute_energy()' function # -------------------------------------- # E = compute_energy(geom_vectors, cartesian=bool) # 'geom_vectors' is either:
from compute_energy import pes from peslearn.ml import NeuralNetwork from peslearn import InputProcessor import torch import numpy as np from itertools import combinations from communicate.get_energy import read_eg nn = NeuralNetwork('/home/luoshu/PycharmProjects/gaus_ipi/PES.dat', InputProcessor(''), molecule_type='A2B') params = { 'layers': (128, 128, 128), 'morse_transform': { 'morse': True, 'morse_alpha': 1.3 }, 'pip': { 'degree_reduction': False, 'pip': True }, 'scale_X': { 'activation': 'tanh', 'scale_X': 'mm11' }, 'scale_y': 'std', 'lr': 0.5 } X, y, Xscaler, yscaler = nn.preprocess(params, nn.raw_X, nn.raw_y) model = torch.load('/home/luoshu/PycharmProjects/gaus_ipi/model.pt')