【问题标题】:I imported tensorflow as tf in notebook and run it successfully, but when I used tf.__version__ it says NameError: name 'tf' is not defined. Help me我在笔记本中将 tensorflow 作为 tf 导入并成功运行,但是当我使用 tf.__version__ 时,它显示 NameError: name 'tf' is not defined。帮我
【发布时间】:2021-12-02 10:30:27
【问题描述】:

Image here 第一个块运行没有任何错误。但第二个说名称错误 tf 未定义,即使我已将 tensorflow 导入为 tf。

【问题讨论】:

    标签: python tensorflow virtual virtual-environment


    【解决方案1】:

    是的,简单

       import tensorflow as tf
       print(tf.__version__)
    

    另外,检查它是否已安装。

    【讨论】:

    • 我做的完全一样。你可以在我附上的图片中看到它。问题依然存在。
    【解决方案2】:

    在这种情况下,我建议将 tensorflow 回滚到以前的稳定版本。这可能是当前版本的错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-02
      • 2021-02-05
      相关资源
      最近更新 更多