ValueError:操作“ mixed10 / concat”没有名为“ _XlaCompile”的属性

问题描述

我正在尝试使用SHAP DeepExplainer解释我的Keras两类分类器。如果可能有用的信息,我将在kaggle Kernel中运行笔记本。

这是我与SHAP相关的代码

import cv2  
import keras.backend as K
import numpy as np
import shap
    
im = cv2.imread(filename)
im = cv2.resize(cv2.cvtColor(im,cv2.COLOR_BGR2RGB),(178,218)).astype(np.float32) / 255.0
im = np.expand_dims(im,axis =0)

e = shap.DeepExplainer(model,im)

shap_values,indexes = e.shap_values(im) 

type(model)返回:

keras.engine.training.Model

imnumpy.ndarray。示例:

array([[[[0.19607843,0.16078432,0.14117648],[0.19607843,...,[0.20392157,0.14509805],[0.2,0.16470589,0.14509805]],[[0.39215687,0.29411766,0.17254902],[0.29411766,0.20392157,0.08235294],[0.28235295,0.1882353,0.07843138],[0.08235294,0.04313726,0.03921569],[0.09019608,0.05098039,0.04313726],[0.08627451,0.05490196,0.04313726]]]],dtype=float32)

代码在第shap_values,indexes = e.shap_values(im)行失败:

ValueError: Operation 'mixed10/concat' has no attr named '_XlaCompile'.

During handling of the above exception,another exception occurred:
AssertionError: 1th input to mixed10/concat cannot vary!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)