【问题标题】:import import tensorflow_docs error on Colab在 Colab 上导入导入 tensorflow_docs 错误
【发布时间】:2022-08-20 23:37:57
【问题描述】:

我已经使用 colab 进行深度学习一个多月了,突然间import tensorflow_docs as tfdocs 停止工作。有没有人遇到同样的问题???

我正在运行 tf.版本2.8.2

> !pip install git+https://github.com/tensorflow/docs
> 
> import tensorflow_docs as tfdocs   
> import tensorflow_docs.modeling   
> import tensorflow_docs.plots

错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-8469b6568dc0> in <module>()
      2 get_ipython().system(\'pip install git+https://github.com/tensorflow/docs\')
      3 
----> 4 import tensorflow_docs as tfdocs
      5 import tensorflow_docs.modeling
      6 import tensorflow_docs.plots

4 frames
/usr/local/lib/python3.7/dist-packages/tensorflow_docs/api_generator/reference_resolver.py in ReferenceResolver()
     86       py_module_names: Union[list[str], dict[str, str]],
     87       link_prefix: Optional[str] = None,
---> 88       physical_path: Optional[dict[str, str]] = None,
     89   ):
     90     \"\"\"Initializes a Reference Resolver.

TypeError: \'type\' object is not subscriptable

编辑:第二天一切都恢复正常,没有任何变化。

    标签: tensorflow callback google-colaboratory tensorboard


    【解决方案1】:

    我也有这个问题,可惜我没有解决办法。但是,这是我迄今为止尝试过的:

    • 降级到 TensorFlow 2.6
    • 安装以前版本的tensorflow_docs!pip install git+https://github.com/tensorflow/docs@my_version 选择为my_version 几周前的提交。
    • 用另一种方式安装tensorflow_docs,先用!git clone https://github.com/tensorflow/docs下载,再用!pip install docs/安装

    都没有成功。

    无论如何,从错误来看,这似乎是tensorflow_docs'ReferenceResolver 的问题,看起来它无法找到库。但是通过以下指令tensorflow-docs 被发现:

    !pip3 freeze | grep tensorflow
    

    【讨论】:

    • 谢谢。我尝试降级 TF 并重新安装。我确实注意到最近在过去 24 小时内对 tensorflow/docs 存储库进行了更改,所以这可能是他们将很快解决的意外后果。我还在本地安装了当前版本的 tensorflow_docs 进行检查,它运行良好。这与 CoLab 相关。
    【解决方案2】:

    我在 colab 中使用 tensorflow 的脚本也有问题,该脚本已经运行了几个月没有任何问题。 突然,我开始遇到与您提到的相同的错误:

    TypeError: 'type' object is not subscriptable
    

    该脚本在脚本顶部的以下行中完成:

    from tensorflow_docs.vis import embed
    

    我刚刚评论了这一行,脚本又开始工作了……:

    # from tensorflow_docs.vis import embed
    

    我希望这可以帮助你们中的一些人有同样的错误。

    【讨论】:

      【解决方案3】:

      你可以试试这个:

      !pip install -q git+https://github.com/MJAHMADEE/docs
      import tensorflow_docs as tfdocs   
      import tensorflow_docs.modeling   
      import tensorflow_docs.plots
      

      【讨论】:

        猜你喜欢
        • 2020-11-28
        • 2021-03-30
        • 1970-01-01
        • 2020-02-23
        • 2019-01-28
        • 2021-06-06
        • 2022-08-06
        • 1970-01-01
        • 2016-11-05
        相关资源
        最近更新 更多