类激活图偏移

问题描述

我正在尝试为我的EfficientNet分类获取类激活图。我正在使用Keras(而不是Tensorflow Keras),这是我用于EfficientNet的代码https://github.com/qubvel/efficientnet

类激活图的实现非常简单:

    class_weights = model.layers[-1].get_weights()[0]
    conv_output = model.get_layer(name_last_conv)
    get_output = K.function([model.layers[0].input],[conv_output.output,model.layers[-1].output])
    [conv_outputs,predictions] = get_output([input2model])
    conv_outputs = conv_outputs[0,:,:]

    # Create the class activation map
    cam = np.zeros(dtype=np.float32,shape=conv_outputs.shape[0:2])
    target_class = 1
    for i,w in enumerate(class_weights[:,target_class]):
        cam += w*conv_outputs[:,i]

我的问题是CAM从实际触发检测的区域偏移了。我使用了显着性贴图,并且得到了我期望的区域,所以我猜测CAM不合适。

我的猜测是,从32x32激活图到实际的1024x1024图像的升采样应该以不同的方式进行以说明填充池,但是我似乎无法正确地做到这一点。有什么办法吗?

任何提示将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)