twni2016 / pomdp-baselines

Simple (but often Strong) Baselines for POMDPs in PyTorch, ICML 2022
https://sites.google.com/view/pomdp-baselines
MIT License
287 stars 41 forks source link

TypeError at POMDPWrapper #18

Closed SandervanL closed 1 year ago

SandervanL commented 1 year ago

Dear,

I encountered the following error when trying to execute your code:

Traceback (most recent call last):
  File "<path>\pomdp-baselines\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "<path>\pomdp-baselines\policies\learner.py", line 420, in collect_rollouts
    obs = ptu.from_numpy(self.train_env.reset(seed=self.seed))  # reset
  File "<path>\pomdp-baselines\venv\lib\site-packages\gym\wrappers\time_limit.py", line 68, in reset
    return self.env.reset(**kwargs)
  File "<path>\pomdp-baselines\venv\lib\site-packages\gym\wrappers\order_enforcing.py", line 42, in reset
    return self.env.reset(**kwargs)
  File "<path>\pomdp-baselines\venv\lib\site-packages\gym\wrappers\env_checker.py", line 45, in reset
    return env_reset_passive_checker(self.env, **kwargs)
  File "<path>\pomdp-baselines\venv\lib\site-packages\gym\utils\passive_env_checker.py", line 192, in env_reset_passive_checker
    result = env.reset(**kwargs)
  File "<path>\pomdp-baselines\envs\pomdp\wrappers.py", line 32, in reset
    return self.get_obs(state)
  File "<path>\pomdp-baselines\envs\pomdp\wrappers.py", line 28, in get_obs
    return state[self.partially_obs_dims].copy()
TypeError: tuple indices must be integers or slices, not list

At the error line, state = ([-0.001 -0.02 -0.023 0.049], {}) is a tuple of a list and a dictionary: , and self.partially_obs_dims = [1, 3] is a list.

I executed the following command: python policies/main.py -cfg configs/pomdp/cartpole/v/rnn.yml --algo sacd

I am running Python 3.9.7, with the following requirements (installing your conda environment did not work for me on Windows):

absl-py==1.4.0
astunparse==1.6.3
box2d-py==2.3.5
cachetools==5.3.1
certifi==2023.5.7
charset-normalizer==3.2.0
cloudpickle==2.2.1
contourpy==1.1.0
cycler==0.11.0
filelock==3.12.2
flatbuffers==23.5.26
fonttools==4.41.0
gast==0.4.0
google-auth==2.22.0
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
grpcio==1.56.0
gym==0.26.2
gym-notices==0.0.8
h5py==3.9.0
idna==3.4
importlib-metadata==6.8.0
importlib-resources==6.0.0
Jinja2==3.1.2
joblib==1.3.1
keras==2.10.0
Keras-Preprocessing==1.1.2
kiwisolver==1.4.4
libclang==16.0.6
Markdown==3.4.3
MarkupSafe==2.1.3
matplotlib==3.7.2
mpmath==1.3.0
networkx==3.1
numpy==1.25.1
oauthlib==3.2.2
opencv-python==4.8.0.74
opt-einsum==3.3.0
packaging==23.1
pandas==2.0.3
Pillow==10.0.0
protobuf==3.19.6
psutil==5.9.5
pyasn1==0.5.0
pyasn1-modules==0.3.0
pybullet==3.2.5
pycolab==1.2
pygame==2.1.0
swig==4.1.1
sympy==1.12
tensorboard==2.10.1
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorflow==2.10.1
tensorflow-estimator==2.10.0
tensorflow-io-gcs-filesystem==0.31.0
termcolor==2.3.0
threadpoolctl==3.2.0
torch==2.0.1
typing_extensions==4.7.1
tzdata==2023.3
urllib3==1.26.16
Werkzeug==2.3.6
wrapt==1.15.0
zipp==3.16.2
SandervanL commented 1 year ago

Seems like this is because of a gym update. Downgrading gym worked, as well as updating the code to expect a second info returned value on env.reset, as well as expecting terminated, truncated instead of done when calling env.step