baselines icon indicating copy to clipboard operation
baselines copied to clipboard

Could you explain how to execute PPO and TRPO?

Open wonchul-kim opened this issue 9 years ago • 18 comments

There is readme explaining all the process to execute deepqn algorithm.

However, there is no such thing for PPO and TRPO....

Could you please explain how to execute PPO and TRPO?

wonchul-kim avatar Jul 25 '17 01:07 wonchul-kim

@wonchul-kim I think a good starting point can be to take a look into run_mujoco.py or run_atari.py You can see there a number of parameters used. In

def main():
    train('Hopper-v1', num_timesteps=1e6, seed=0)

You can write a name of the environment you want to run. Also you can modify train function to add more training parameters into it that later can be exposed to the command line.

To run Atari you should also set num_cpu to 1.

ViktorM avatar Jul 26 '17 01:07 ViktorM

Thanks for your reply!!

I've looked through your code and study... However, I keep getting error messages.. .when i run it...

my computer environment is ubuntu16.04 and python2.7

The error message i got is this: Traceback (most recent call last): File "run_mujoco.py", line 3, in from baselines import bench ImportError: cannot import name bench

when i typed " python run_mujoco.py"

I checked the bench folder and init.py ..... I don't think there is a problem... but not sure..

Could you help me...?

wonchul-kim avatar Jul 26 '17 10:07 wonchul-kim

use python 3, instead

andrewliao11 avatar Jul 26 '17 11:07 andrewliao11

I typed "python3 run_mujoco.py" then the below came up

Traceback (most recent call last): File "run_mujoco.py", line 2, in from baselines.common import set_global_seeds, tf_util as U ImportError: No module named 'baselines'

I don't think that is the answer

wonchul-kim avatar Jul 26 '17 11:07 wonchul-kim

not sure about how you install the package, yet maybe try add the baselines into your PYTHONPATH?

andrewliao11 avatar Jul 26 '17 11:07 andrewliao11

What I have done is that I downloaded the entire code and just typed "python run_mujoco.py" Is there anything that has to be done before running it?

wonchul-kim avatar Jul 26 '17 11:07 wonchul-kim

@wonchul-kim add import sys sys.path.append('your baselines's parent folder') in run_mujoco.py

shijcnju avatar Jul 26 '17 12:07 shijcnju

Typical Python2/Python3 conflict. Just use pip3 install baselines or python3 -m pip install baselines

pip install * install by default for python2

Just an advice, try to be more confident with python before using advanced library ;)

Amathlog avatar Jul 26 '17 14:07 Amathlog

I have already installed baselines by pip install baselines

wonchul-kim avatar Jul 26 '17 14:07 wonchul-kim

pip install * install by default for python2

You installed it for python2 not python3. Read my reply again

Amathlog avatar Jul 26 '17 14:07 Amathlog

Is baselines based on python3???

If not, i want to use it with python2.7, because all of work I've done is by python2.7.

wonchul-kim avatar Jul 26 '17 14:07 wonchul-kim

Located in baselines setup.py: if sys.version_info.major != 3: print("This Python is only compatible with Python 3, but you are running " "Python {}. The installation will likely fail.".format(sys.version_info.major))

So yes, only python3

Amathlog avatar Jul 26 '17 14:07 Amathlog

Thank you!! So,,, version is the problem,,,,

Sinece you are more experienced than I am, is python3 better than python2?? I am just worried about compatibility things,,,,

wonchul-kim avatar Jul 26 '17 14:07 wonchul-kim

It's an evolution of the language. It is newer and use new things. The first change you'll see is that print is now a function Python2: print "Hello World!" Python3: print("Hello World!") but there is a lot more, and it's not really the topic of this thread ^^ See there : https://docs.python.org/3/howto/pyporting.html

Amathlog avatar Jul 26 '17 14:07 Amathlog

Thank you for your advice!!!

I will try to use it!!

Thank you!!!

wonchul-kim avatar Jul 26 '17 14:07 wonchul-kim

Thank you for your reply...

However, there still came up the same error: Traceback (most recent call last): File "run_mujoco.py", line 3, in from baselines import bench ImportError: cannot import name 'bench'

after i installed with 'sudo python3 install baselines' and typed 'python3 run_mujoco.py'.....

I really.... have no idea.... (on a side note, i could successfully run deepq with 'python3 -m baselines.deepq.experiments.train_cartpole')

2017-07-26 23:45 GMT+09:00 Adrien LOGUT [email protected]:

It's an evolution of the language. It is newer and use new things. The first change you'll see is that print is now a function Python2: print "Hello World! Python3: print("Hello World!") but there is a lot more, and it's not really the topic of this thread ^^ See there : https://docs.python.org/3/howto/pyporting.html

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/openai/baselines/issues/67#issuecomment-318075272, or mute the thread https://github.com/notifications/unsubscribe-auth/AT7jwZ8-wsObjS_aL0St3bAWoGq63ACzks5sR1D1gaJpZM4Oh80Z .

wonchul-kim avatar Jul 27 '17 07:07 wonchul-kim

@wonchul-kim To avoid worrying about Python2 vs Python3 compatibility issues, make separate virtual environments, one for each version. Alternatively (as I do) make separate conda environments. I have one conda environment which I created specifically for Python 3 and TensorFlow 1.2 material.

DanielTakeshi avatar Jul 28 '17 05:07 DanielTakeshi

For the 'cannot import name 'bench'' issue you can try adding export PYTHONPATH="${PYTHONPATH}:/home//baselines" to ~/.bashrc and then sourcing bashrc. Worked for me. Also you should be using python3 for baselines. When installing with pip I write "sudo pip3 install xxxx" when installing for python3.

silverjoda avatar Aug 17 '17 09:08 silverjoda