0

我正在尝试为 TF-Agents 创建我自己的 PyEnvironment。但是,此错误不断出现:

AttributeError:模块“tensorflow.python.ops.linalg.linear_operator_util”没有属性“matmul_with_broadcast”

我发现这似乎是一个问题tensorflow-probability,但我已经安装了https://github.com/tensorflow/agents/issues/91tensorflow-probability=0.7.0推荐 的版本

我试过重新安装和更新

tensorflow-gpu=2.0.0-beta1 tf-agents-nightly tensorflow-probability=0.7.0

这是一个最小的代码示例:

from tf_agents.environments import py_environment


class myEnv(py_environment.PyEnvironment):
    def __init__(self):
        pass

    def _reset(self):
        pass

    def _step(self, action):
        pass

这是运行此最小示例时的完整错误消息:

Traceback (most recent call last):   File ".\env_mwe.py", line 1, in <module>
    from tf_agents.environments import py_environment   File "C:\Python37\lib\site-packages\tf_agents\environments\__init__.py", line 18, in <module>
    from tf_agents.environments import batched_py_environment   File "C:\Python37\lib\site-packages\tf_agents\environments\batched_py_environment.py", line 33, in <module>
    from tf_agents.environments import py_environment   File "C:\Python37\lib\site-packages\tf_agents\environments\py_environment.py", line 29, in <module>
    from tf_agents.trajectories import time_step as ts   File "C:\Python37\lib\site-packages\tf_agents\trajectories\__init__.py", line 19, in <module>
    from tf_agents.trajectories import time_step   File "C:\Python37\lib\site-packages\tf_agents\trajectories\time_step.py", line 28, in <module>
    from tf_agents.specs import array_spec   File "C:\Python37\lib\site-packages\tf_agents\specs\__init__.py", line 20, in <module>
    from tf_agents.specs.distribution_spec import DistributionSpec   File "C:\Python37\lib\site-packages\tf_agents\specs\distribution_spec.py", line 22, in <module>
    import tensorflow_probability as tfp   File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\__init__.py", line 78, in <module>
    from tensorflow_probability.python import *  # pylint: disable=wildcard-import   File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\__init__.py", line 22, in <module>
    from tensorflow_probability.python import distributions   File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\distributions\__init__.py", line 64, in <module>
    from tensorflow_probability.python.distributions.linear_gaussian_ssm import LinearGaussianStateSpaceModel   File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\distributions\linear_gaussian_ssm.py", line 41, in <module>
    _matmul = linear_operator_util.matmul_with_broadcast AttributeError: module 'tensorflow.python.ops.linalg.linear_operator_util' has no attribute 'matmul_with_broadcast'
4

2 回答 2

1

找到了!

为了使用tensorflow-gpuwith tensorflow-probability,需要安装tfp-nightly

pip3 install --upgrade tfp-nightly诀窍也是如此

于 2019-08-16T17:35:07.297 回答
1

使用2.0.0beta1需要tfp-nightly.

于 2019-08-19T14:21:16.930 回答