ikostrikov / pytorch-a2c-ppo-acktr-gail

PyTorch implementation of Advantage Actor Critic (A2C), Proximal Policy Optimization (PPO), Scalable trust-region method for deep reinforcement learning using Kronecker-factored approximation (ACKTR) and Generative Adversarial Imitation Learning (GAIL).
MIT License
3.62k stars 827 forks source link

Env Observation space dimension error whenever I try to train any model #191

Open ashwinipokle opened 5 years ago

ashwinipokle commented 5 years ago

Hello,

I followed steps mentioned here to install requirements for this repository. There is one minor change, I am using virtualenv instead of conda to install pytorch. I wanted to test my installation and I tried to train model using the commands mentioned in this section. I am unable to get any model to train. Everytime I get the following error.

Traceback (most recent call last): File "main.py", line 14, in from a2c_ppo_acktr import algo, utils File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/algo/init.py", line 1, in from .a2c_acktr import A2C_ACKTR File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/algo/a2c_acktr.py", line 5, in from a2c_ppo_acktr.algo.kfac import KFACOptimizer File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/algo/kfac.py", line 8, in from a2c_ppo_acktr.utils import AddBias File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/utils.py", line 7, in from a2c_ppo_acktr.envs import VecNormalize File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/envs.py", line 146 assert len(op) == 3, f"Error: Operation, {str(op)}, must be dim3"

ashwinipokle commented 5 years ago

Quick update: I followed installation instructions in anaconda environment and I still get a similar error whenever I try to train model. Traceback (most recent call last): File "main.py", line 166, in main() File "main.py", line 46, in main base_kwargs={'recurrent': args.recurrent_policy}) File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/model.py", line 21, in init if len(obs_shape) == 3: TypeError: object of type 'NoneType' has no len()

Seems like this is an issue with the version of OpenAI gym being used. Could you please let me know which version of OpenAI gym is compatible with the codebase ?

YuiiCh commented 5 years ago

me too

ikostrikov commented 5 years ago

It seems to work for me (I tested it with the latest versions of gym and baselines). Could you check whether you install the latest versions of gym and baselines?

I ran

 python main.py --env-name "PongNoFrameskip-v4"
niagl commented 5 years ago

Tried with latest versions of gym and baseline. The issue still remains. Any ideas here ?

YuiiCh commented 5 years ago

Thank you, now it works~

发件人: Nikhil Agarwal 发送时间: 2019年6月12日 3:20 收件人: ikostrikov/pytorch-a2c-ppo-acktr-gail 抄送: YuiiCh; Comment 主题: Re: [ikostrikov/pytorch-a2c-ppo-acktr-gail] Env Observation spacedimension error whenever I try to train any model (#191)

Tried with latest versions of gym and baseline. The issue still remains. Any ideas here ? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

henrycharlesworth commented 5 years ago

For me it was because I was using Python 3.5, once I updated to 3.6 it was working (I was getting the error: pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/envs.py", line 146 assert len(op) == 3, f"Error: Operation, {str(op)}, must be dim3")

Looking at the code there:

super(TransposeImage, self).init(env) assert len(op) == 3, f"Error: Operation, {str(op)}, must be dim3"

It's using an f-string which is only supported in >=Python 3.6. So I think this means that this code won't work in Python 3.5 (which is annoying, as I can only get mujoco-py to run in python 3.5... but that's a whole different issue!). It might be worth mentioning this somewhere!