Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Args:
graph: tensor flow graph.
sess: the current session.
y: the pre-softmax activation we want to assess attribution with respect to.
image: float32 image tensor with size [1, None, None].
saliency_method: string indicating saliency map type to generate.
Returns:
a saliency map and a smoothed saliency map.
Raises:
ValueError: if the saliency_method string does not match any included method
"""
if saliency_method == 'integrated_gradients':
integrated_placeholder = saliency.IntegratedGradients(graph, sess, y, image)
return integrated_placeholder
elif saliency_method == 'gradient':
gradient_placeholder = saliency.GradientSaliency(graph, sess, y, image)
return gradient_placeholder
elif saliency_method == 'guided_backprop':
gb_placeholder = saliency.GuidedBackprop(graph, sess, y, image)
return gb_placeholder
else:
raise ValueError('No saliency method method matched. Verification of'
'input needed')