def load(self, model_path):
    if (self.sess is not None):
        self.sess.close()
    if (self.graph is not None):
        self.graph = None
    model_prefix = os.path.join(model_path, 'deepfm')
    print('Load model...', model_path, file=sys.stderr)
    self.sess = tf1.Session()
    saver = tf1.train.import_meta_graph((model_prefix + '.meta'), clear_devices=True)
    saver.restore(self.sess, model_prefix)
    self.feat_index = tf1.get_default_graph().get_tensor_by_name('feat_index:0')
    self.feat_value = tf1.get_default_graph().get_tensor_by_name('feat_value:0')
    self.dropout_keep_fm = tf1.get_default_graph().get_tensor_by_name('dropout_keep_fm:0')
    self.dropout_keep_deep = tf1.get_default_graph().get_tensor_by_name('dropout_keep_deep:0')
    self.train_phase = tf1.get_default_graph().get_tensor_by_name('train_phase:0')
    self.out = tf1.get_default_graph().get_tensor_by_name('out:0')
    config_path = os.path.join(model_path, 'config.json')
    if os.path.exists(config_path):
        with open(config_path) as fp:
            self._config = json.load(fp)
    else:
        self._config = None
    print('Load model done', model_path, file=sys.stderr)
def load(self, model_path):
    if (self.sess is not None):
        self.sess.close()
    if (self.graph is not None):
        self.graph = None
    model_prefix = os.path.join(model_path, 'deepfm')
    print('Load model...', model_path, file=sys.stderr)
    self.sess = tf1.Session()
    saver = tf1.train.import_meta_graph((model_prefix + '.meta'), clear_devices=True)
    saver.restore(self.sess, model_prefix)
    self.feat_index = tf1.get_default_graph().get_tensor_by_name('feat_index:0')
    self.feat_value = tf1.get_default_graph().get_tensor_by_name('feat_value:0')
    self.dropout_keep_fm = tf1.get_default_graph().get_tensor_by_name('dropout_keep_fm:0')
    self.dropout_keep_deep = tf1.get_default_graph().get_tensor_by_name('dropout_keep_deep:0')
    self.train_phase = tf1.get_default_graph().get_tensor_by_name('train_phase:0')
    self.out = tf1.get_default_graph().get_tensor_by_name('out:0')
    config_path = os.path.join(model_path, 'config.json')
    if os.path.exists(config_path):
        with open(config_path) as fp:
            self._config = json.load(fp)
    else:
        self._config = None
    print('Load model done', model_path, file=sys.stderr)