Skip to content
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

"ValueError: Dimension Mismatch" in Step 4: Run the ICLR algorithms #4

Open
Cozokim opened this issue Sep 19, 2024 · 1 comment
Open

Comments

@Cozokim
Copy link

Cozokim commented Sep 19, 2024

Hi !
When I'm launching te step 4 of the Part I. [ICRL in Virtual Environment] as the tutorial suggest, (https://github.com/Guiliang/ICRL-benchmarks-public/blob/main/virtual_env_tutorial.md)

Run GAIL
python train_gail.py ../config/mujuco_BlockedHalfCheetah/train_GAIL_HCWithPos-v0.yaml -n 5 -s 123

I'm encountering the following error when trying to run my code:

Traceback (most recent call last):
  File "/path/to/project/interface/train_gail.py", line 363, in <module>
    train(args)
  File "/path/to/project/interface/train_gail.py", line 290, in train
    model.learn(total_timesteps=int(config['PPO']['timesteps']),
  File "/path/to/project/stable_baselines3/ppo/ppo.py", line 255, in learn
    return super(PPO, self).learn(
  File "/path/to/project/stable_baselines3/common/on_policy_algorithm.py", line 231, in learn
    continue_training = self.collect_rollouts(self.env, callback, self.rollout_buffer, n_rollout_steps=self.n_steps)
  File "/path/to/project/stable_baselines3/common/on_policy_algorithm.py", line 198, in collect_rollouts
    callback.on_rollout_end()
  File "/path/to/project/stable_baselines3/common/callbacks.py", line 100, in on_rollout_end
    self._on_rollout_end()
  File "/path/to/project/stable_baselines3/common/callbacks.py", line 200, in _on_rollout_end
    callback.on_rollout_end()
  File "/path/to/project/stable_baselines3/common/callbacks.py", line 100, in on_rollout_end
    self._on_rollout_end()
  File "/path/to/project/constraint_models/constraint_net/gail_net.py", line 657, in _on_rollout_end
    metrics = self.discriminator.train(1, obs, acs)
  File "/path/to/project/constraint_models/constraint_net/gail_net.py", line 199, in train
    nominal_data, _ = self.prepare_nominal_data(nominal_obs, nominal_acs)
  File "/path/to/project/constraint_models/constraint_net/gail_net.py", line 352, in prepare_nominal_data
    concat = self.select_appropriate_dims(np.concatenate([obs, acs], axis=-1))
  File "<__array_function__ internals>", line 5, in concatenate
ValueError: all the input arrays must have the same number of dimensions, but the array at index 0 has 2 dimension(s) and the array at index 1 has 3 dimension(s)

The issue seems to arise from a mismatch in the dimensions of the input arrays when concatenating observations (obs) and actions (acs).

I have gym==0.21.0

I'm trying to run the ICLR algorithms using the Blocked Half-Cheetah environment to reproduce the results from Section 4.2 of the paper. Any help in resolving this would be greatly appreciated!

Thanks in Advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@Cozokim and others