-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue importing keras-rl on tensorflow-macos #380
Comments
Hi, I've had some problems with keras-rl and tensorflow and I managed to find a solution to this problem, after hours of trying to figure it out. Hopefully it works for you too.
Once you install My issues here these:
Hopefully this helps. |
hello everyone, can you help me to solve this issue File /opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/init.py:1 File /opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/dqn.py:8 File /opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/policy.py:3 ImportError: cannot import name 'model_from_config' from 'tensorflow.keras.models' (/opt/anaconda3/envs/py311/lib/python3.11/site-packages/keras/_tf_keras/keras/models/init.py) |
do you got it? |
Hello Ashok Kushwaha,
Unfortunately, I was unable to resolve this issue.
Since I had a project to hand in, I used a different library.
I hope to come back to it soon.
Sincerely,
Iroda Radjabova.
…On Thu, 18 Apr 2024 at 07:53 Ashok Kushwaha ***@***.***> wrote:
hello everyone, can you help me to solve this issue ImportError Traceback
(most recent call last) Cell In[11], line 5 3 from keras import *version*
4 tf.keras.*version* = *version* ----> 5 from rl.agents import DQNAgent 6
from rl.policy import BoltzmannQPolicy 7 from rl.memory import
SequentialMemory
File /opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/
*init*.py:1
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/__init__.py:1>
----> 1
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/__init__.py:1>
from .dqn import DQNAgent, NAFAgent, ContinuousDQNAgent 2
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/__init__.py:2>
from .ddpg import DDPGAgent 3
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/__init__.py:3>
from .cem import CEMAgent
File
/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/dqn.py:8
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/dqn.py:8>
5
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/dqn.py:5>
from tensorflow.keras.layers import Lambda, Input, Layer, Dense 7
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/dqn.py:7>
from rl.core import Agent ----> 8
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/dqn.py:8>
from rl.policy import EpsGreedyQPolicy, GreedyQPolicy 9
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/dqn.py:9>
from rl.util import * 12
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/agents/dqn.py:12>
def mean_q(y_true, y_pred):
File /opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/policy.py:3
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/policy.py:3>
1
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/policy.py:1>
import numpy as np ----> 3
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/policy.py:3>
from rl.util import * 6
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/policy.py:6>
class Policy: ... ----> 3
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/util.py:3>
from tensorflow.keras.models import model_from_config, Sequential, Model,
model_from_config 4
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/util.py:4>
import tensorflow.keras.optimizers as optimizers 5
<https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/py311/lib/python3.11/site-packages/rl/util.py:5>
import tensorflow.keras.backend as K
ImportError: cannot import name 'model_from_config' from
'tensorflow.keras.models'
(/opt/anaconda3/envs/py311/lib/python3.11/site-packages/keras/_tf_keras/keras/models/
*init*.py) I've tried to solve this issue in python version 3.9, 3.8,
3.11, 3.10
do you got it?
—
Reply to this email directly, view it on GitHub
<#380 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A6XKKZTAAVGWQ7AOX6KNVHTY54YT5AVCNFSM5DZTNIU2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBWGI4TAMBYGE3Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
The tensorflow-macos branch is currently archived so I was hoping someone could help me find a fix for this Import error. Im trying to import keras-rl packages and its throwing errors because TensorFlow does not have a function that keras uses during import. Idk if there's a previous version of keras-rl that would fix this or if I'm kinda just boned until TensorFlow has proper support for the m1 chip. logs below, package versions listed from pip also below. (run on a jupyter notebook and a minforge/conda venv)
jupyter-client 7.0.2
jupyter-core 4.7.1
jupyterlab-pygments 0.1.2
tensorflow-addons-macos 0.1a3
tensorflow-estimator 2.5.0
tensorflow-macos 0.1a3
keras 2.6.0
keras-rl 0.4.2
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Flatten
from tensorflow.keras.optimizers import Adam
from rl.agents.dqn import DQNAgent
from rl.policy import BoltzmannQPolicy
from rl.memory import SequentialMemory
ImportError Traceback (most recent call last)
/var/folders/mt/kt4lp3rx2p37sfswrnyhlkjr0000gn/T/ipykernel_2558/438834739.py in
----> 1 from rl.agents.dqn import DQNAgent
2 from rl.policy import BoltzmannQPolicy
3 from rl.memory import SequentialMemory
~/miniforge3/envs/tensorflow/lib/python3.8/site-packages/rl/agents/init.py in
1 from future import absolute_import
----> 2 from .dqn import DQNAgent, NAFAgent, ContinuousDQNAgent
3 from .ddpg import DDPGAgent
4 from .cem import CEMAgent
5 from .sarsa import SarsaAgent, SARSAAgent
~/miniforge3/envs/tensorflow/lib/python3.8/site-packages/rl/agents/dqn.py in
2 import warnings
3
----> 4 import keras.backend as K
5 from keras.models import Model
6 from keras.layers import Lambda, Input, Layer, Dense
~/miniforge3/envs/tensorflow/lib/python3.8/site-packages/keras/init.py in
23
24 # See b/110718070#comment18 for more details about this import.
---> 25 from keras import models
26
27 from keras.engine.input_layer import Input
~/miniforge3/envs/tensorflow/lib/python3.8/site-packages/keras/models.py in
17
18 import tensorflow.compat.v2 as tf
---> 19 from keras import backend
20 from keras import metrics as metrics_module
21 from keras import optimizer_v1
~/miniforge3/envs/tensorflow/lib/python3.8/site-packages/keras/backend.py in
34 from tensorflow.core.protobuf import config_pb2
35 from tensorflow.python.eager import context
---> 36 from tensorflow.python.eager.context import get_config
37 from tensorflow.python.framework import config
38 from keras import backend_config
ImportError: cannot import name 'get_config' from 'tensorflow.python.eager.context' (/Users/sebastian/miniforge3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/eager/context.py)
The text was updated successfully, but these errors were encountered: