问题描述
尝试使用anaconda环境导入在Tensorflow 2.3.0上运行的tf_agents.environments时遇到此错误.试图重新安装tensorflow,仍然出现相同的错误.以管理员身份运行jupyter笔记本时,仍然出现相同的错误.我正在使用python 3.8
Getting this error when trying to import tf_agents.environments running on Tensorflow 2.3.0, using anaconda environment. Have tried to reinstall tensorflow, still getting same error. Running the jupyter notebook in as admin, still getting same error. I am using python 3.8
from tf_agents.environments import suite_gym
ImportError Traceback (most recent call last)
<ipython-input-8-b9cd8ac2787f> in <module>
----> 1 from tf_agents.environments import suite_gym
2
3 # env = suite_gym.load("Breakout-v4")
4 # env
~\AppData\Roaming\Python\Python38\site-packages\tf_agents\environments\__init__.py in <module>
24 from tf_agents.environments import tf_py_environment
25 from tf_agents.environments import trajectory_replay
---> 26 from tf_agents.environments import utils
27 from tf_agents.environments import wrappers
~\AppData\Roaming\Python\Python38\site-packages\tf_agents\environments\utils.py in <module>
23 from tf_agents.environments import tf_environment
24 from tf_agents.environments import tf_py_environment
---> 25 from tf_agents.policies import random_py_policy
26 from tf_agents.specs import array_spec
27
~\AppData\Roaming\Python\Python38\site-packages\tf_agents\policies\__init__.py in <module>
16 """Policies Module."""
17
---> 18 from tf_agents.policies import actor_policy
19 from tf_agents.policies import boltzmann_policy
20 from tf_agents.policies import epsilon_greedy_policy
~\AppData\Roaming\Python\Python38\site-packages\tf_agents\policies\actor_policy.py in <module>
27 import tensorflow_probability as tfp
28
---> 29 from tf_agents.networks import network
30 from tf_agents.policies import tf_policy
31 from tf_agents.specs import tensor_spec
~\AppData\Roaming\Python\Python38\site-packages\tf_agents\networks\__init__.py in <module>
16 """Networks Module."""
17
---> 18 from tf_agents.networks import actor_distribution_network
19 from tf_agents.networks import actor_distribution_rnn_network
20 from tf_agents.networks import bias_layer
~\AppData\Roaming\Python\Python38\site-packages\tf_agents\networks\actor_distribution_network.py in <module>
24 import tensorflow as tf # pylint: disable=g-explicit-tensorflow-version-import
25
---> 26 from tf_agents.networks import categorical_projection_network
27 from tf_agents.networks import encoding_network
28 from tf_agents.networks import network
~\AppData\Roaming\Python\Python38\site-packages\tf_agents\networks\categorical_projection_network.py in <module>
24 import tensorflow_probability as tfp
25
---> 26 from tf_agents.networks import network
27 from tf_agents.networks import utils
28 from tf_agents.specs import distribution_spec
~\AppData\Roaming\Python\Python38\site-packages\tf_agents\networks\network.py in <module>
31
32 # pylint:disable=g-direct-tensorflow-import
---> 33 from tensorflow.python.keras.engine import network as keras_network # TF internal
34 from tensorflow.python.training.tracking import base # TF internal
35 from tensorflow.python.util import tf_decorator # TF internal
ImportError: cannot import name 'network' from 'tensorflow.python.keras.engine' (C:\Users\Vision\anaconda3\envs\tf2\lib\site-packages\tensorflow\python\keras\engine\__init__.py)
推荐答案
这里有点晚,但面临类似的问题.
Am a bit late here, but faced a similar issue.
我如何解决此问题:
卸载当前版本的tf_agents
,使用
pip uninstall tf-agents
请安装当前的tf-agents-nightly
(0.6.0) GitHub存储库.
Please install the current tf-agents-nightly
(0.6.0) GitHub Repo.
使用pip install tf-agents-nightly
from tf_agents.environments import suite_gym
这篇关于ImportError:无法从'tensorflow.python.keras.engine'导入名称'network'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!