Closed sherlock42 closed 5 years ago
Exactly like for 1-channel images, except that attributions for the three channels should then be summed up together. See https://github.com/marcoancona/DeepExplain/blob/master/examples/mint_cnn_keras.ipynb
I was trying to use it for a dataset with only 2 classes. I tried to run deepexplain for one single image of my datastet (The label of the image is 0)
`with DeepExplain(session=K.get_session()) as de: # <-- init DeepExplain context
# With Keras this is very easy:
# 1. Get the input tensor to the original model
input_tensor = model3.layers[0].input
# 2. We now target the output of the last dense layer (pre-softmax)
# To do so, create a new model sharing the same layers untill the last dense (index -2)
fModel = Model(inputs=input_tensor, outputs = model3.layers[-2].output)
target_tensor = fModel(input_tensor)
xs = img_tensor
y_test= np.array([0])
ys=y_test
attributions_gradin = de.explain('grad*input', target_tensor, input_tensor, xs, ys=ys)
#attributions_sal = de.explain('saliency', target_tensor, input_tensor, xs, ys=ys)
#attributions_ig = de.explain('intgrad', target_tensor, input_tensor, xs, ys=ys)
#attributions_dl = de.explain('deeplift', target_tensor, input_tensor, xs, ys=ys)
#attributions_elrp = de.explain('elrp', target_tensor, input_tensor, xs, ys=ys)
#attributions_occ = de.explain('occlusion', target_tensor, input_tensor, xs, ys=ys)`
but I keep getting the following error
`--------------------------------------------------------------------------- ValueError Traceback (most recent call last)
how can we use deep explain for 3 channel images with keras backend?