import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.keras import...print('img.shape',img.shape)
# plt.figure("Image") # 图像窗口名称
# plt.imshow(img)
# plt.axis('on') # 关掉坐标轴为...(Predictions[0])] # 最大可能性类别的预测概率
grads = gtape.gradient(prob, conv_output) # 类别与卷积层的梯度 (1,14,14,512...)
print('grads',grads)
pooled_grads = K.mean(grads, axis=(0,1,2)) # 特征层梯度的全局平均代表每个特征层权重
heatmap...= tf.reduce_mean(tf.multiply(pooled_grads, conv_output), axis=-1) #权重与特征层相乘,512层求和平均
# print('heatmap