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

Error when running the tutorial code #360

Open
WangJuan6 opened this issue Jun 27, 2024 · 0 comments
Open

Error when running the tutorial code #360

WangJuan6 opened this issue Jun 27, 2024 · 0 comments

Comments

@WangJuan6
Copy link

Hi,
I run the tutorial code by python tutorial_PPO.py, but I got an error:

  Traceback (most recent call last):
  File "/data/projects/20240627/ElegantRL/helloworld/tutorial_PPO.py", line 65, in <module>
    train_ppo_for_pendulum(GPU_ID)
  File "/data/projects/20240627/ElegantRL/helloworld/tutorial_PPO.py", line 31, in train_ppo_for_pendulum
    train_agent(args)
  File "/data/projects/20240627/ElegantRL/helloworld/run.py", line 40, in train_agent
    buffer_items = agent.explore_env(env, horizon_len)
  File "/data/projects/20240627/ElegantRL/helloworld/agent.py", line 207, in explore_env
    state = torch.as_tensor(ary_state, dtype=torch.float32, device=self.device)
ValueError: expected sequence of length 3 at dim 1 (got 0)

To solve this problem, I change the code in agent.py:
change
state = torch.as_tensor(ary_state, dtype=torch.float32, device=self.device)
into
state = torch.as_tensor(ary_state[0], dtype=torch.float32, device=self.device)
but I got a new error:

Traceback (most recent call last):
  File "/data/projects/20240627/ElegantRL/helloworld/tutorial_PPO.py", line 65, in <module>
    train_ppo_for_pendulum(GPU_ID)
  File "/data/projects/20240627/ElegantRL/helloworld/tutorial_PPO.py", line 31, in train_ppo_for_pendulum
    train_agent(args)
  File "/data/projects/20240627/ElegantRL/helloworld/run.py", line 40, in train_agent
    buffer_items = agent.explore_env(env, horizon_len)
  File "/data/projects/20240627/ElegantRL/helloworld/agent.py", line 211, in explore_env
    ary_state, reward, done, _ = env.step(ary_action)
  File "/data/projects/20240627/ElegantRL/helloworld/env.py", line 24, in step
    state, reward, done, info_dict = self.env.step(action * 2)
ValueError: too many values to unpack (expected 4)

Can you help me to solve these problems?
Thanks

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

1 participant