我的简化模型如下:
model = Sequential()
model.add(LSTM(12, input_shape=(1000,12)))
model.add(Dense(9, activation='sigmoid'))
我的训练数据具有以下形状:
(900,1000,12)
从输出层可以看到,我有9个输出,因此每个信号(长度为1000)将被分类为一个或多个该输出(这是多标签分类)
我像这样训练我的模型:
history = model.fit(X_train,y_train, batch_size=32, epochs=10,validation_data=(X_val,y_val),verbose=2)
到目前为止,一切都还可以,但是现在我想用Lime来解释分类
explainer = lime_tabular.RecurrentTabularExplainer(X_train, training_labels=y_train,feature_names=['1','2','3','4','5','6','7','8','9','10','11','12'],
discretize_continuous=True,
class_names=['a','b','c','d','e','f','g','h','i'],
discretizer='decile')
定义解释器时我没有收到任何错误,但是当我尝试运行下面的代码时,由于给我一个错误,它运行了很长时间
exp=explainer.explain_instance(data_row=X[0].reshape(1,1000,12),classifier_fn= model)
exp.show_in_notebook()
NotImplementedError: LIME does not currently support classifier models without probability scores.
If this conflicts with your use case, please let us know: https://github.com/datascienceinc/lime/issues/16
任何人都可以识别此错误或看到什么错误吗?
答案 0 :(得分:0)
model = Sequential()
model.add(LSTM(12, input_shape=(1000,12)))
model.add(Dense(9, activation='softmax'))