Closed rao208 closed 4 years ago
facing the same issue, any solution?
@ShreyashSoni Yes, the problem was I wasn't using the right activation function to get the probability score for both the classes. What I mean is, if you use a softmax activation function in the final layer (even if the dataset has two labels), you will get the probability score for both of them whereas if you use any other activation function then you will just get the probability for one class.
It is important to have the probability score for both the class because when we call tf explain Occlusion Sensitivity, we must specify the class index.
output = explainer.explain(data, new_model, class_index = classindex, patch_size = 4)
I hope it helps!
@rao208 thanks for the explanation. this helps
I am trying to apply occlusion sensitivity on the "cats_vs_dog" dataset. First, the model is trained as given in the link https://www.tensorflow.org/tutorials/images/transfer_learning and then the trained model and the sample image is loaded to carry out occlusion sensitivity.
In an amateur attempt, the following lines were added in the code for tf-explain.
It works fine for class 0 i.e. cats but fails to produce results for class 1 i.e. dogs.
Traceback (most recent call last):
The complete code is:
Also, the occlusion sensitivity method works fine on the pre-trained model like MobileNet or VGG but doesn't work on the own model.