Search code examples
nlpgradientbert-language-model

Integrated Gradients Error - Attempt to convert a value (None) with an unsupported type (<class 'NoneType'>) to a Tensor


I am new to transformers, but I managed to create a Bert classifier using tensorflow and now I want to implement Integreted Gradients to explain the model, ,but I get this error:

Attempt to convert a value (None) with an unsupported type (<class 'NoneType'>) to a Tensor

If you think that you can help, please find my code here: link because it is a lot of code to paste in here.


Solution

  • In your notebook, the error is triggered by

    explanation = ig.explain(a,
                             baselines=None,
                             target=predictions)
    

    Therefore, it seems that ig requires non-empty baselines.