sicara/tf-explain

[Bug Report] - Error in true_divide -> All ResnetV2 Keras Models

Meywether opened this issue · 4 comments

Dear Sicara,
thanks for this great easy-to-use library.
I do have to mention a bug in your script if I am using one of the ResnetV2 Models:
Starting with a small modified version of your provided example, tf-explain throws following error by using:

  • ResNet50V2
  • ResNet101V2
  • ResNet152V2

The "V1" Versions are working properly. -> Tested with all three variants!

The script throws following error:

image

Thanks in advance!
Best regards
Meywether

Attached: My version of your provided example:

image

@Meywether This might be due to heatmap.min being equal to heatmap.max. You might want to remove the last softmax layer of the Resnet to prevent this from happening.

@Meywether This might be due to heatmap.min being equal to heatmap.max. You might want to remove the last softmax layer of the Resnet to prevent this from happening.

@RaphaelMeudec is right here. Even I had the same issue. I resolved it by removing the last layer from my pre-trained model.

Hello @RaphaelMeudec and @nishantagarwal ,
thanks for your response.

model = tf.keras.applications.resnet_v2.ResNet50V2(weights="imagenet", include_top=False) - is not working

So I created a second model by using:
model2 = Model(model.input, model.layers[-2].output)

model2.summary() shows me that the props layer is gone, but still getting the same error

I thought that model2 = Model(model.input, model.layers[-1].output) should be enough but in my case the Dense probs layer was still in my model.

May I ask you to provide me a code snippet ?

Best regards

Meywether

I have the same problem as @Meywether , with a custom keras model with multi output ( segmentation and classification).