I created a CNN using TensorFlow2 and trained it as a binary classifier. Is there a way to extract the influence of each pixel upon the prediction?
I am trying to obtain a mask similar to the following:
Data Science Stack Exchange is a question and answer site for Data science professionals, Machine Learning specialists, and those interested in learning more about the field. It only takes a minute to sign up.Sign up to join this community
You are looking for GradCam.
This is a good resource I found https://christophm.github.io/interpretable-ml-book/
from tf_explain.callbacks.grad_cam import GradCAMCallback model = [...] callbacks = [ GradCAMCallback( validation_data=(x_val, y_val), class_index=0, output_dir=output_dir, ) ] model.fit(x_train, y_train, batch_size=2, epochs=2, callbacks=callbacks)