Hello,
I used a Resnet50 based model(Resnet50+average pooling+ flatten+ dense) for medical RBG images and applied the code below for plotting its gradient map. Why is the output only a totally black one?
def load_image(path, target_size=(224, 224)):
x = image.load_img(path, target_size=target_size)
x = image.img_to_array(x)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
x= x/(target_size[0])
print(x)
return x
img_path = 'test.jpeg'
from keras.preprocessing import image
import matplotlib.pyplot as plot
img_width, img_height=224,224
img = load_image(path=img_path, target_size=(img_width, img_height))
Hello, I used a Resnet50 based model(Resnet50+average pooling+ flatten+ dense) for medical RBG images and applied the code below for plotting its gradient map. Why is the output only a totally black one? def load_image(path, target_size=(224, 224)): x = image.load_img(path, target_size=target_size) x = image.img_to_array(x) x = np.expand_dims(x, axis=0) x = preprocess_input(x) x= x/(target_size[0]) print(x) return x
img_path = 'test.jpeg' from keras.preprocessing import image import matplotlib.pyplot as plot img_width, img_height=224,224 img = load_image(path=img_path, target_size=(img_width, img_height))
model_wo_sm = iutils.keras.graph.model_wo_softmax(model) gradient_analyzer = innvestigate.analyzer.Gradient(model_wo_sm) analysis = gradient_analyzer.analyze(img) plot.imshow(analysis.squeeze()) plot.show()