Example #1
0
import numpy as np
from deepmd.env import tf
from collections import defaultdict
from deepmd.TabInter import TabInter
from deepmd.common import ClassArg

from deepmd.RunOptions import global_tf_float_precision
from deepmd.RunOptions import global_np_float_precision
from deepmd.RunOptions import global_ener_float_precision
from deepmd.RunOptions import global_cvt_2_tf_float
from deepmd.RunOptions import global_cvt_2_ener_float

module_path = os.path.dirname(os.path.realpath(__file__)) + "/"
assert (os.path.isfile(module_path +
                       "libop_abi.so")), "op module does not exist"
op_module = tf.load_op_library(module_path + "libop_abi.so")


class Model():
    model_type = 'ener'

    def __init__(self, jdata, descrpt, fitting):
        self.descrpt = descrpt
        self.rcut = self.descrpt.get_rcut()
        self.ntypes = self.descrpt.get_ntypes()
        # fitting
        self.fitting = fitting
        self.numb_fparam = self.fitting.get_numb_fparam()

        args = ClassArg()\
               .add('type_map',         list,   default = []) \
Example #2
0
import os,sys
import numpy as np

from deepmd.env import tf

from tensorflow.python.framework import ops

if platform.system() == "Windows":
    ext = "dll"
elif platform.system() == "Darwin":
    ext = "dylib"
else:
    ext = "so"
module_path = os.path.dirname(os.path.realpath(__file__))
assert (os.path.isfile (os.path.join(module_path, "libop_abi.{}".format(ext)))), "op module does not exist"
op_module = tf.load_op_library(os.path.join(module_path, "libop_abi.{}".format(ext)))

class DeepEval():
    """
    common methods for DeepPot, DeepWFC, DeepPolar, ...
    """
    def __init__(self, 
                 model_file) :
        model_file = model_file
        graph = self.load_graph (model_file)
        t_mt = graph.get_tensor_by_name('load/model_attr/model_type:0')
        sess = tf.Session (graph = graph)        
        [mt] = sess.run([t_mt], feed_dict = {})
        self.model_type = mt.decode('utf-8')

    def load_graph(self, 
Example #3
0
dir = os.path.dirname(os.path.realpath(__file__))

from tensorflow.python.framework import ops

# load force module
if platform.system() == "Windows":
    ext = "dll"
elif platform.system() == "Darwin":
    ext = "dylib"
else:
    ext = "so"
module_path = os.path.dirname(os.path.realpath(__file__)) + "/../"
assert (os.path.isfile(module_path + "deepmd/libop_abi.{}".format(ext))
        ), "force module does not exist"
op_module = tf.load_op_library(module_path + "deepmd/libop_abi.{}".format(ext))

# load grad of force module
sys.path.append(module_path)
import deepmd._prod_force_grad
import deepmd._prod_virial_grad
import deepmd._prod_force_se_a_grad
import deepmd._prod_virial_se_a_grad
import deepmd._prod_force_se_r_grad
import deepmd._prod_virial_se_r_grad
import deepmd._soft_min_force_grad
import deepmd._soft_min_virial_grad


def _make_node_names(model_type=None):
    if model_type == 'ener':
Example #4
0
#!/usr/bin/env python3

import os, sys
import numpy as np

from deepmd.env import tf

from tensorflow.python.framework import ops
module_path = os.path.dirname(os.path.realpath(__file__))
assert (os.path.isfile(os.path.join(
    module_path, "libop_abi.so"))), "op module does not exist"
op_module = tf.load_op_library(os.path.join(module_path, "libop_abi.so"))


class DeepEval():
    """
    common methods for DeepPot, DeepWFC, DeepPolar, ...
    """
    def __init__(self, model_file):
        model_file = model_file
        graph = self.load_graph(model_file)
        t_mt = graph.get_tensor_by_name('load/model_attr/model_type:0')
        sess = tf.Session(graph=graph)
        [mt] = sess.run([t_mt], feed_dict={})
        self.model_type = mt.decode('utf-8')

    def load_graph(self, frozen_graph_filename, prefix='load'):
        # We load the protobuf file from the disk and parse it to retrieve the
        # unserialized graph_def
        with tf.gfile.GFile(frozen_graph_filename, "rb") as f:
            graph_def = tf.GraphDef()