// pylint: disable=E0611
import os
from art import DATA_PATH
tf = import_tensorflow_v1()
from tensorflow.python.saved_model import tag_constants
full_path = os.path.join(DATA_PATH, state["model_name"])
graph = tf.Graph()
sess = tf.Session(graph=graph)
loaded = tf.saved_model.loader.load(sess, [tag_constants.SERVING], full_path)
// Recover session
self._sess = sess
// Recover input_ph
input_tensor_name = loaded.signature_def["predict"].inputs["SavedInputPhD"].name
self._input_ph = graph.get_tensor_by_name(input_tensor_name)
// Recover output layer
self._output = graph.get_tensor_by_name(state["_output"])
// Recover labels" placeholder if any
if state["_labels_ph"] is not None:
self._labels_ph = graph.get_tensor_by_name(state["_labels_ph"])
// Recover loss if any
if state["_loss"] is not None:
self._loss = graph.get_tensor_by_name(state["_loss"])
// Recover loss_grads if any
if state["_loss_grads"]:
self._loss_grads = graph.get_tensor_by_name(state["_loss_grads"])
else:
self.__dict__.pop("_loss_grads", None)
// Recover learning if any
if state["_learning"] is not None:
self._learning = graph.get_tensor_by_name(state["_learning"])
// Recover train if any
if state["_train"] is not None: