使用Keras模型的DeepExplainer,“ LookupError:渐变注册表没有条目:shap_TensorListStack”

时间:2020-10-06 12:48:32

标签: tensorflow keras shap

将DeepExplainer用于Keras顺序模型进行多类文本分类时,出现以下错误。请在下面找到详细信息:

## KERAS版本:2.4.3。

## MODEL

model = Sequential()
model.add(InputLayer (input_shape= (max_len ,)))
model.add(Embedding (vocab_size +1 , embed_dim , input_length= max_len, weights[embed_matrix]))
model.add(LSTM (LSTM_unit , dropout= dropouts, recurrent_dropout=dropouts,return_sequences=False))
model.add(Dense (6 , activation="softmax"))
##DEEPEXPLAINER

explainer = shap.DeepExplainer(model, X_train[:100], learning_phase_flags = None)
shap_values = explainer.shap_values(X_test[:10])

错误

LookupError: gradient registry has no entry for: shap_TensorListStack

请帮助我解决此问题。我已经尝试了存储库中提到的问题中提供的所有可能的解决方案,但无法解决此错误。

最好的问候, 梅格纳·戈亚(Meghna Goyal)

0 个答案:

没有答案