Keras 类激活映射偏移量

Keras 类激活映射偏移量,keras,deep-learning,classification,Keras,Deep Learning,Classification,我正在尝试为我的EfficientNet分类器获取类激活映射。我使用的是Keras(不是Tensorflow Keras),这是我为我的效率网使用的代码: 类激活映射实现非常简单: class_weights = model.layers[-1].get_weights()[0] conv_output = model.get_layer(name_last_conv) get_output = K.function([model.layers[0].input], [c

我正在尝试为我的EfficientNet分类器获取类激活映射。我使用的是Keras(不是Tensorflow Keras),这是我为我的效率网使用的代码:

类激活映射实现非常简单:

    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有点不对劲

我的猜测是,从32x32激活映射到实际1024x1024图像的上采样应该以另一种方式进行,以说明填充池,但我似乎无法正确实现这一点。有没有办法做到这一点


任何提示都将不胜感激。

请使用xdeep库,该库不适用于我的Keras代码。我得到一个错误:模型没有“eval”属性