def __init__(self, graph, session, y, x, tmp_ckpt_path='/tmp/guided_backprop_ckpt'):
    'Constructs a GuidedBackprop SaliencyMask.'
    super(GuidedBackprop, self).__init__(graph, session, y, x)
    self.x = x
    if (GuidedBackprop.GuidedReluRegistered is False):

        @tf.RegisterGradient('GuidedRelu')
        def _GuidedReluGrad(op, grad):
            gate_g = tf.cast((grad > 0), 'float32')
            gate_y = tf.cast((op.outputs[0] > 0), 'float32')
            return ((gate_y * gate_g) * grad)
    GuidedBackprop.GuidedReluRegistered = True
    with graph.as_default():
        saver = tf.train.Saver()
        saver.save(session, tmp_ckpt_path)
    graph_def = graph.as_graph_def()
    self.guided_graph = tf.Graph()
    with self.guided_graph.as_default():
        self.guided_sess = tf.Session(graph=self.guided_graph)
        with self.guided_graph.gradient_override_map({'Relu': 'GuidedRelu'}):
            tf.import_graph_def(graph_def, name='')
            saver.restore(self.guided_sess, tmp_ckpt_path)
            imported_y = self.guided_graph.get_tensor_by_name(y.name)
            imported_x = self.guided_graph.get_tensor_by_name(x.name)
            self.guided_grads_node = tf.gradients(imported_y, imported_x)[0]
Constructs a GuidedBackprop SaliencyMask.
def __init__(self, graph, session, y, x, tmp_ckpt_path='/tmp/guided_backprop_ckpt'):
    
    super(GuidedBackprop, self).__init__(graph, session, y, x)
    self.x = x
    if (GuidedBackprop.GuidedReluRegistered is False):

        @tf.RegisterGradient('GuidedRelu')
        def _GuidedReluGrad(op, grad):
            gate_g = tf.cast((grad > 0), 'float32')
            gate_y = tf.cast((op.outputs[0] > 0), 'float32')
            return ((gate_y * gate_g) * grad)
    GuidedBackprop.GuidedReluRegistered = True
    with graph.as_default():
        saver = tf.train.Saver()
        saver.save(session, tmp_ckpt_path)
    graph_def = graph.as_graph_def()
    self.guided_graph = tf.Graph()
    with self.guided_graph.as_default():
        self.guided_sess = tf.Session(graph=self.guided_graph)
        with self.guided_graph.gradient_override_map({'Relu': 'GuidedRelu'}):
            tf.import_graph_def(graph_def, name=)
            saver.restore(self.guided_sess, tmp_ckpt_path)
            imported_y = self.guided_graph.get_tensor_by_name(y.name)
            imported_x = self.guided_graph.get_tensor_by_name(x.name)
            self.guided_grads_node = tf.gradients(imported_y, imported_x)[0]