PaddlePaddle / PARL

A high-performance distributed training framework for Reinforcement Learning
https://parl.readthedocs.io/
Apache License 2.0
3.27k stars 820 forks source link

无法引用:cannot import name 'layers' from 'parl #612

Open longqianlanqiu opened 3 years ago

longqianlanqiu commented 3 years ago

在B站学习paddleDQN算法时尝试复现,运行代码报错:ImportError: cannot import name 'layers' from 'parl' (C:\Users\lenovo\anaconda3\envs\paddle_env\lib\site-packages\parl__init__.py) paddle版本是:paddlepaddle-gpu 2.0.2.post110 parl版本是:parl 1.4.3 windows10

TomorrowIsAnOtherDay commented 3 years ago

hello,十分感谢你的issue。 B站对应的课程是基于静态图版本开发的,目前你安装的2.0版本属于动态图版本,你得安装对应的版本才行。 关于版本的问题我们已经在课程对应的目录下面做了提示,请参考这个说明

longqianlanqiu commented 3 years ago

谢谢周末还回复~ 那我可以使用:import paddle.fluid.layers as layers 这段代码吗? 运行时暂时没有报错

TomorrowIsAnOtherDay commented 3 years ago

https://github.com/PaddlePaddle/PARL/blob/ab1eb893a9f0ac1d5238c6a5277ea7e7c6cd1fdf/examples/DQN/cartpole_model.py#L17

建议还是使用上面这行代码引入layers。 通过这种方式构建的网络,PARL框架才可以把定位到创建的参数并进行更新。

Saber-xxf commented 2 years ago

你好 你这是parl版本问题 新版的舍弃了这个方法,你可以去examples/DQN/CartpoleModel.py中查看最新的方法

LHTLiu commented 2 years ago

您好,我先使用的是pycharm,都直接搜不到paddlepaddle的版本是1.63的?想直接使用最新版本的库,还怎么操作呀?

TomorrowIsAnOtherDay commented 2 years ago

你使用的是哪个版本的python?

zhangxy24 commented 2 years ago

您好,我也是搜不到paddlepaddle1.6.3的版本,python版本3.9,请问怎么解决,同时安装parl1.3.1出现错误

LHTLiu commented 2 years ago

你看看回答,3.9版本的python就不支持

zhangxy24 commented 2 years ago

[07-04 17:05:00 MainThread @logger.py:242] Argv: G:/1.python_code/DDPG_test/train.py [07-04 17:05:01 MainThread @utils.py:73] paddlepaddle version: 2.3.0. E:\9.Python 3.9.7\lib\site-packages\gym\spaces\box.py:112: UserWarning: WARN: Box bound precision lowered by casting to float32 logger.warn(f"Box bound precision lowered by casting to {self.dtype}") Traceback (most recent call last): File "G:\1.python_code\DDPG_test\train.py", line 108, in main() File "G:\1.python_code\DDPG_test\train.py", line 94, in main run_train_episode(agent, env, rpm) File "G:\1.python_code\DDPG_test\train.py", line 33, in run_train_episode next_obs, reward, done, info = env.step(action) File "G:\1.python_code\DDPG_test\env.py", line 69, in step assert self.action_space.contains(action), \ AssertionError: array([0.19881878]) (<class 'numpy.ndarray'>) invalid

为什么git_hub上的代码出现如上错误,paddle2.0 parl2.0 gym 0.24.1

fulequn commented 2 years ago

[07-04 17:05:00 MainThread @logger.py:242] Argv: G:/1.python_code/DDPG_test/train.py [07-04 17:05:01 MainThread @utils.py:73] paddlepaddle version: 2.3.0. E:\9.Python 3.9.7\lib\site-packages\gym\spaces\box.py:112: UserWarning: WARN: Box bound precision lowered by casting to float32 logger.warn(f"Box bound precision lowered by casting to {self.dtype}") Traceback (most recent call last): File "G:\1.python_code\DDPG_test\train.py", line 108, in main() File "G:\1.python_code\DDPG_test\train.py", line 94, in main run_train_episode(agent, env, rpm) File "G:\1.python_code\DDPG_test\train.py", line 33, in run_train_episode next_obs, reward, done, info = env.step(action) File "G:\1.python_code\DDPG_test\env.py", line 69, in step assert self.action_space.contains(action), AssertionError: array([0.19881878]) (<class 'numpy.ndarray'>) invalid

为什么git_hub上的代码出现如上错误,paddle2.0 parl2.0 gym 0.24.1

你这个好像是gym的版本高了,应该考虑降低gym的版本