hiranumn / IntegratedGradients

Python/Keras implementation of integrated gradients presented in "Axiomatic Attribution for Deep Networks" for explaining any model defined in Keras framework.
MIT License
216 stars 51 forks source link

global name 'model1' not defined #7

Closed jmschrei closed 6 years ago

jmschrei commented 6 years ago

When trying to run with a dense feedforward network I get the following error:

Traceback (most recent call last):
  File "avocado_fit.py", line 66, in <module>
    ig = integrated_gradients(model)
  File "/net/noble/vol1/home/jmschr/proj/avocado/exps/2_13_18_Intepretability/IntegratedGradients.py", line 57, in __init__
    self.outchannels = range(model1.output._keras_shape[1])
NameError: global name 'model1' is not defined

This can be traced back to this code:

if len(self.outchannels) == 0:
            if verbose: print("Evaluated output channel (0-based index): All")
            if K.backend() == "tensorflow":
                self.outchannels = range(self.model.output.shape[1]._value)
            elif K.backend() == "theano":
                self.outchannels = range(model1.output._keras_shape[1])

model1 isn't defined. I switched it over to model, is that the right fix?

hiranumn commented 6 years ago

This is the right fix. I would switch to self.model. I will push the change.