keras shap.deepexplainer错误对象类型的非电视'没有Len()

发布于 2025-02-04 07:19:04 字数 613 浏览 3 评论 0原文

我正在尝试使用TensorFlow推荐和Keras构建推荐模型。 我正在尝试使用Shap库获得模型解释性,但是,我面临问题,因为我有子类Keras Model

`我正在使用示例

import shap

background = train_np[np.random.choice(train_np.shape[0], 100, replace=False)]
explainer = shap.DeepExplainer(model, background)

​/code>

框架/usr/local/lib/python3.7/dist-packages/shap/rupplioners/tf_utils.py in _get_model_output(模型)83 isInstance(Model,tf.keras.model) [-1] ._ inbound_nodes)== 0:---> 85如果Len(Model.Outputs)> 1:86警告。WARN(“仅支持一个模型输出。”)87返回模型。输出[0] typeError:类型'nontype'的对象没有Len()

任何建议?

I am trying to build a recommendation model using TensorFlow recommender and Keras.
I am trying to get model explainability using SHAP library, however, I am facing an issue as I have sub class keras model

` I am using the example https://www.tensorflow.org/recommenders/examples/multitask'

import shap

background = train_np[np.random.choice(train_np.shape[0], 100, replace=False)]
explainer = shap.DeepExplainer(model, background)

i am getting an error when running Shap

frames/usr/local/lib/python3.7/dist-packages/shap/explainers/tf_utils.py in _get_model_output(model) 83 isinstance(model, tf.keras.Model): 84 if len(model.layers[-1]._inbound_nodes) == 0: ---> 85 if len(model.outputs) > 1: 86 warnings.warn("Only one model output supported.") 87 return model.outputs[0] TypeError: object of type 'NoneType' has no len()

Any suggestions ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文