in tcav/model.py [0:0]
def __init__(self, model_path=None, node_dict=None):
"""Initialize the wrapper.
Optionally create a session, load
the model from model_path to this session, and map the
input/output and bottleneck tensors.
Args:
model_path: one of the following: 1) Directory path to checkpoint 2)
Directory path to SavedModel 3) File path to frozen graph.pb 4) File
path to frozen graph.pbtxt
node_dict: mapping from a short name to full input/output and bottleneck
tensor names. Users should pass 'input' and 'prediction'
as keys and the corresponding input and prediction tensor
names as values in node_dict. Users can additionally pass bottleneck
tensor names for which gradient Ops will be added later.
"""
# A dictionary of bottleneck tensors.
self.bottlenecks_tensors = None
# A dictionary of input, 'logit' and prediction tensors.
self.ends = None
# The model name string.
self.model_name = None
# a place holder for index of the neuron/class of interest.
# usually defined under the graph. For example:
# with g.as_default():
# self.tf.placeholder(tf.int64, shape=[None])
self.y_input = None
# The tensor representing the loss (used to calculate derivative).
self.loss = None
# If tensors in the loaded graph are prefixed with 'import/'
self.import_prefix = False
if model_path:
self._try_loading_model(model_path)
if node_dict:
self._find_ends_and_bottleneck_tensors(node_dict)