Giter Club home page Giter Club logo

keras-explain's People

Contributors

jindong-developer avatar jindonggu avatar primozgodec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

keras-explain's Issues

LRP target class

I would like some help with regards to the LRP explainer, I would like to know what is the input type of "target_class" ? I tried inserting a tuple contain image classes retrieve from CIFAR10, but was met with this error.
image

lrp gets some bug

Traceback (most recent call last):
File "/home/xdjf/zingchen/keras_explain/test/test_lrp.py", line 44, in
Test_inception.test_lrp()
File "/home/xdjf/zingchen/keras_explain/test/test_lrp.py", line 40, in test_lrp
LRP, {"model": self.model}, self.images)
File "/home/xdjf/zingchen/keras_explain/test/test_lrp.py", line 34, in _test_approach
exp_pos, exp_neg = explainer.explain(image, 15)
File "/home/xdjf/anaconda3/envs/keras_explain/lib/python3.6/site-packages/keras_explain-0.0.1-py3.6.egg/keras_explain/lrp.py", line 33, in explain
File "/home/xdjf/anaconda3/envs/keras_explain/lib/python3.6/site-packages/keras_explain-0.0.1-py3.6.egg/keras_explain/lrp.py", line 134, in get_layers_outputs
AttributeError: 'NoneType' object has no attribute 'output'

Process finished with exit code 1

Visualizing explenation Error

Hi Primoz,
i am trying to use your toolbox for visualizations of an inceptionv3 model.
When i try to transform the explanation array into an image i get the following error:

exp_heatmap = cv2.resize(exp_heatmap, (c_original.shape[1], c_original.shape[0])) TypeError: Expected cv::UMat for argument 'src'
see the following gist for code. https://gist.github.com/randmized/6c506086fb8e92518529c188ed22c558

could you elaborate on the output and how eventually getting an image written to file?
Also i was not able to find documentation other then https://pypi.org/project/keras-explain/ and the github repository.

all best

Hard-coded for 3-channel (RGB) images

I tried to use "PredictionDiff" for MNIST images and found that it was coded to only accept RGB images. It was relatively easy for me to open the code and make it work for grayscale images.

I recommend adding variables that calculate the number of channels and use that instead of "3" everywhere in the code.

Lime error

Hi,

I am trying to figure out how to use this toolbox (great project, btw, many thanks for creating it!). I took a model and an image an ran the Lime explainer for them with the correct class prediction - something reasonable came out. Then I randomly changed the target class index to 8 (the model has 89 classes so it's there all right) and got this error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-34-c7232aa8ce1b> in <module>()
      7 print(classIdx, pred[0][classIdx])
      8 
----> 9 pos,neg = explainer.explain(img, 8)

/usr/local/lib/python3.6/site-packages/keras_explain/lime_ribeiro.py in explain(self, image, target_class)
     16             image, self.model.predict, top_labels=5, num_samples=1000)
     17         temp, mask = explanation.get_image_and_mask(
---> 18             target_class, positive_only=False, num_features=10, hide_rest=True)
     19 
     20         return (mask == 2).astype(int), (mask == 1).astype(int)

/usr/local/lib/python3.6/site-packages/lime/lime_image.py in get_image_and_mask(self, label, positive_only, hide_rest, num_features, min_weight)
     49         """
     50         if label not in self.local_exp:
---> 51             raise KeyError('Label not in explanation')
     52         segments = self.segments
     53         image = self.image

KeyError: 'Label not in explanation'

Can you help me with this?

Thanks!

LRP SOFTMAX

If I ask for an explanation on a model with softmax as last layer i get:
LayerNotImplementedException
I think it can be easily removed simply not considering the last softmax layer

LRP: problem in conv2d when padding = 'same'

when I use padding='same' in conv2d layers i get error.
basic example:
m = Sequential()
m.add(Conv2D(512, kernel_size=(3, 3),
activation='relu', padding='same',
input_shape=(14,14,512),strides=(1,1)))
m.add(MaxPooling2D(pool_size=(2,2)))
m.summary()

explainer = LRP(m)
exp = explainer.explain(numpy.ones((14,14,512)), 3)[0]

error: ValueError: operands could not be broadcast together with shapes (1,3,3,512,512) (1,3,2,512,1)

this is a problem especially in already trained model (e.g., vgg16)

FailedPreconditionError

Loading model image and using any of the methods returns FailedPreconditionError.

FailedPreconditionError: 2 root error(s) found.
  (0) Failed precondition: Error while reading resource variable block5_conv1_2/kernel from Container: localhost. This could mean that the variable was uninitialized. Not found: Container localhost does not exist. (Could not find resource: localhost/block5_conv1_2/kernel)
	 [[{{node model_2/block5_conv1/Conv2D/ReadVariableOp}}]]
	 [[gradients/model_2/block1_conv1/Conv2D_grad/Conv2DBackpropInput/_11]]
  (1) Failed precondition: Error while reading resource variable block5_conv1_2/kernel from Container: localhost. This could mean that the variable was uninitialized. Not found: Container localhost does not exist. (Could not find resource: localhost/block5_conv1_2/kernel)
	 [[{{node model_2/block5_conv1/Conv2D/ReadVariableOp}}]]

My code:

model = load_model(os.getcwd() + "/models/saved_models_for_fusion/0_FusionVGGMnistToPS.h5")
img_path = str(Path(os.getcwd() + "/models/scripts/xxx.jpg"))
img = load_img(img_path)
explainer = Saliency(model, layer=3)
exp = explainer.explain(img, 0)

I think that the resolution can be found here:
tensorflow/tensorflow#28287 (comment) is it possible to check whether this can fix this issue? It seems that loading model and using model.predict() fails due to not thread-safe operations.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.