【问题标题】:Unable to import tensorflow_hub in Jupyter Notebook无法在 Jupyter Notebook 中导入 tensorflow_hub
【发布时间】:2021-12-09 01:53:23
【问题描述】:

我正在测试这个 BERT 教程视频提供的代码:https://www.youtube.com/watch?v=7kLi8u2dJz0。但是,我在尝试导入以下软件包时遇到了困难:

import tensorflow_hub as hub    
import tensorflow_text as text 

错误提示:

ImportError:无法从部分初始化的模块“tensorflow_estimator.python.estimator.canned.dnn”导入名称“dnn_logit_fn_builder”(很可能是由于循环导入)(C:\Users\X\anaconda3\lib\site-packages \tensorflow_estimator\python\estimator\canned\dnn.py)

有什么办法可以解决这个问题吗?

【问题讨论】:

    标签: python tensorflow jupyter-notebook bert-language-model


    【解决方案1】:

    尝试使用以下代码:

    !pip install tensorflow_text
    !pip install tensorflow_hub
    
    import tensorflow_hub as hub    
    import tensorflow_text as text 
    

    如果仍然显示相同的错误,请在您的程序中添加以下代码:

    import tensorflow as tf
    tf.compat.v1.estimator.experimental.dnn_logit_fn_builder
    

    这可能会解决此错误。如果问题仍然存在,请告诉我们。

    【讨论】:

      猜你喜欢
      • 2019-08-18
      • 2020-11-06
      • 2018-07-28
      • 2019-08-10
      • 1970-01-01
      • 2023-01-23
      • 2017-09-19
      • 2023-04-11
      • 1970-01-01
      相关资源
      最近更新 更多