tensorflow / agents

TF-Agents: A reliable, scalable and easy to use TensorFlow library for Contextual Bandits and Reinforcement Learning.
Apache License 2.0
2.8k stars 722 forks source link

ImportError: cannot import name 'network' from 'tensorflow.python.keras.engine' #436

Closed darkmatter2222 closed 4 years ago

darkmatter2222 commented 4 years ago

What I did:

Upgraded from tensorflow 2.2.0 to tensorflow 2.3.0

Implementation:

from tf_agents.agents.dqn import dqn_agent

Error:

File "C:\Users\ryans\source\repos\venvs\Python375x64CPUTensorflow\lib\site-packages\tf_agents\agents__init.py", line 19, in from tf_agents.agents.behavioral_cloning.behavioral_cloning_agent import BehavioralCloningAgent File "C:\Users\ryans\source\repos\venvs\Python375x64CPUTensorflow\lib\site-packages\tf_agents\agents\behavioral_cloning__init.py", line 17, in from tf_agents.agents.behavioral_cloning import behavioral_cloning_agent File "C:\Users\ryans\source\repos\venvs\Python375x64CPUTensorflow\lib\site-packages\tf_agents\agents\behavioral_cloning\behavioral_cloning_agent.py", line 32, in from tf_agents.policies import epsilon_greedy_policy File "C:\Users\ryans\source\repos\venvs\Python375x64CPUTensorflow\lib\site-packages\tf_agents\policies\init.py", line 18, in from tf_agents.policies import actor_policy File "C:\Users\ryans\source\repos\venvs\Python375x64CPUTensorflow\lib\site-packages\tf_agents\policies\actor_policy.py", line 29, in from tf_agents.networks import network File "C:\Users\ryans\source\repos\venvs\Python375x64CPUTensorflow\lib\site-packages\tf_agents\networks\init__.py", line 18, in from tf_agents.networks import actor_distribution_network File "C:\Users\ryans\source\repos\venvs\Python375x64CPUTensorflow\lib\site-packages\tf_agents\networks\actor_distribution_network.py", line 26, in from tf_agents.networks import categorical_projection_network File "C:\Users\ryans\source\repos\venvs\Python375x64CPUTensorflow\lib\site-packages\tf_agents\networks\categorical_projection_network.py", line 26, in from tf_agents.networks import network File "C:\Users\ryans\source\repos\venvs\Python375x64CPUTensorflow\lib\site-packages\tf_agents\networks\network.py", line 33, in from tensorflow.python.keras.engine import network as keras_network # TF internal ImportError: cannot import name 'network' from 'tensorflow.python.keras.engine' (C:\Users\ryans\source\repos\venvs\Python375x64CPUTensorflow\lib\site-packages\tensorflow\python\keras\engine\init__.py)

signalprime commented 4 years ago

Also searching for the replacement Ref: 41988

ebrevdo commented 4 years ago

You probably need a newer version of tf-agents, e.g., the nightly or most recent release. Each stable version of tf-agents is associated with a stable version of tensorflow; likely updating tensorflow broke the guarantees. Please reopen if that doesn't help.