简体   繁体   English

无法导入 tensorflow_probability

[英]Cannot import tensorflow_probability

When I try to import tensorflow_probability , I get this error:当我尝试import tensorflow_probability时,出现此错误:

Traceback (most recent call last):
  File "PATH", line 1, in <module>
    import tensorflow_probability
  File "PATH", line 75, in <module>
    from tensorflow_probability.python import *  # pylint: disable=wildcard-import
  File "PATH", line 24, in <module>
    from tensorflow_probability.python import edward2
  File "PATH", line 32, in <module>
    from tensorflow_probability.python.experimental.edward2.generated_random_variables import *
  File "PATH", line 34, in <module>
    from tensorflow_probability.python.experimental import auto_batching
  File "PATH", line 24, in <module>
    from tensorflow_probability.python.experimental.auto_batching import frontend
  File "PATH", line 46, in <module>
    from tensorflow.python.autograph.pyct import compiler
ImportError: cannot import name 'compiler' from 'tensorflow.python.autograph.pyct' (PATH)

I don't know why Python can't import this module because when I type pip list in cmd, it tells me that I have tensorflow-probability 0.8.0rc0 installed.我不知道为什么 Python 无法导入此模块,因为当我在 cmd 中键入pip list时,它告诉我安装了tensorflow-probability 0.8.0rc0 Any help would be greatly appreciated.任何帮助将不胜感激。

I have tried to import in Google colab and Ubuntu 18 version.我尝试在Google colabUbuntu 18版本中导入。 In colab it worked directly, in ubuntu I faced issues.colab它直接工作,在 ubuntu 我遇到了问题。
Upgrading to the latest pip and TensorFlow version resolved my issue.升级到最新的 pip 和 TensorFlow 版本解决了我的问题。

Colab:合作实验室:

import tensorflow_probability as tfp  

Ubuntu 18: Ubuntu 18:

Upgrade pip升级pip

pip install --upgrade pip 

install the latest version of TensorFlow安装最新版TensorFlow

pip install tensorflow

install tensorflow_probability安装 tensorflow_probability

pip install --upgrade tensorflow-probability  

tensorflow-probability version 0.11.1张量流概率版本0.11.1

Try to install the tf_agents package.尝试安装tf_agents package。 I had a few import errors appear when trying to import tensorflow_probability .尝试导入tensorflow_probability时出现了一些导入错误。 These include:这些包括:

  • module 'tensorflow.python.ops.linalg.linear_operator' has no attribute 'make_composite_tensor'
  • cannot import name 'all_util' from 'tensorflow_probability.python.internal' . cannot import name 'all_util' from 'tensorflow_probability.python.internal'

These issues were resolved when I installed and imported the tf_agents .当我安装和导入tf_agents时,这些问题得到了解决。

pip install --upgrade tf_agents

If you're using jupyter, add the following to a cell and then run it:如果您使用的是 jupyter,请将以下内容添加到单元格中,然后运行它:

import sys
!{sys.executable} -m pip install --upgrade tf_agents

Had the exact same problem.有完全相同的问题。 Removing older tensorflow version and installing everything nightly solved my problem .删除较旧的 tensorflow 版本并每晚安装所有内容解决了我的问题

pip uninstall tensorflow
pip uninstall tensorflow-probability

pip install tf-nightly
pip install tfp-nightly

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法保存 Tensorflow_probability 模型 - Cannot Save Tensorflow_probability model 尝试导入 tensorflow_probability 时出错(没有名为 keras 的模块) - error when trying to import tensorflow_probability (no module named keras) 没有名为“tensorflow_probability”的模块 - No module named 'tensorflow_probability' 安装时没有名为“tensorflow_probability”的模块 - No module named 'tensorflow_probability' when it's installed tensorflow_probability 子类化 JointDistributionNamed __init__ 行为 - tensorflow_probability subclassing JointDistributionNamed __init__ behaviour 如何使用 tensorflow_probability 解决此问题? - how can i fix this issue with tensorflow_probability? tensorflow_probability 分布应该如何用于多维空间? - How should tensorflow_probability distributions be used for multi-dimensional spaces? 如何正确使用tensorflow_probability从随机变量的函数中采样? - How to correctly use tensorflow_probability to sampling from random variables' function? tensorflow_probability:反向传播正态分布样本的 log_prob 时,梯度始终为零 - tensorflow_probability: Gradients always zero when backpropagating the log_prob of a sample of a normal distribution 无法在ipython中导入Tensorflow - Cannot import Tensorflow in ipython
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM